DRY'd up code by creating new replace-map