Using hasattr instead of type().__name__ per feedback