improve error-handling