Fixed the null pointer exception