security check for avoiding nullpointer exception