fix a bug in replace and contains