use exceptions to simplify error handling.