exception handling and removed debug output