Fix null pointer access