fixed null pointer bug