added catch for Nullpointer exception