Improve calculation of error count