improving exception handling