error handling (Fixes #6)