bug fix at substitution