Refactored object type check