full implementation of temp hysteresis