fix a condition replace bug