Add AttributeError checks

necessary for py3