fixed a null pointer bug