clean up exception handling in code