fix ugly nil pointer reference