fixing a nullpointer exception