Nullpointer exception fix