Enhancing error handling