Handling possible nullpointer exception.