implemented critical error handling