Bugfix
Improve error handling