Removed unused import
Migrated to EAFP for attribute checking