fix bug in applySubst