correctly handle errors
Merge pull request #5 from Clever/handle-errors-correctly

correctly handle errors