Added check for object actually being an object