Fixed possible nil pointer derefence