added hysteresis