Fixed undo replace bug