security check for avoiding null pointer exception