Fix dereference of nil pointer