fix error counting