Use isinstance() instead of comparing with type()