further modification to the way errors are thrown and caught