Refactor replace