Wrote replaceMap to make replacements cleaner.