Preveting null pointer