Fix to dereference NULL pointer