Fixing potential null pointer access