Improves error handling