Fix a null pointer bug