Add error handling

Fixes issue #3