fix a null pointer bug