main error handling rev