Improving exception handling