Make sure the objects are of the same type before compare