added basic hysteresis