almost done rewriting line substitutions