refactor detectAndReportFailures