fix error rate calculation