fix replace pointer bug