Refactor text substitutions