cleaned up exception handler