Added missing null object pointer check