bugfix in error handling