replace method refactoring