error-handling bugfix