Refactor substitutions