Defined subst_apply_safe