Fixed bug in exception handler