bug fix in replace step