Updated code to throw exception on null object.