changed exception handler a bit