fixed issue in replace code