improve error handling
Merge pull request #13 from icholy/master

improve error handling