major search and replace refactor