Fix a bug with Null pointer access