added hysteresis to the control loop