Closes #4 adds error handler