The previous logic was causing the (unintentional) removal of custom defines automatically added by the engine.