Fixed possible nullpointer exception