add exception handling

fixes #8