Added check for nil object before passing an object to it.