Adding check for null object