Adds function to calculate the errorRate