fixes #7, better error handling