Use isinstance() instead of type()