Fixed null pointer access issue