Fix for error handling