handle exceptions in a more centralized way