more replace refactoring