Fixed error threshold hysteresis

Fixed hysteresis detection to +- error_threshold.