proper error handling for async errors