handle exceptions more gracefully