add error count function.