handle errors, fixes #1