fixed a pretty substantial substitution bug