issue #4 - better error handling