Made changes to check for dereference of null pointer