fix substitution bug