fix implementation of subst using staged substitutions