reworked exception handling