fix null pointer bug