Use isinstance instead of comparing type.