Fixing bug in substitution of definitions in QE