multiReplace refactored