fix the null pointer bug