Fixed replace bug