Fixed the null pointer problem