fix some error handling
Merge pull request #26 from specode/master

fix some error handling