Added missing function for error handling