finished implementing substitutions