added normalization to handle non-pattern substitutions