Fixed the null pointer bug.