       case METHOD_TABLE:
 	// calculate target
 	iTable=(struct convert *) conditions[i].target;
-	conditions[i].limit2->value=resolveConversion(value,conditions[i].limit->value,iTable);
-	float radReq=conditions[i].limit2->value;
-	if (!turnBypass(0,ts,radReq))
+	float target=resolveConversion(value,conditions[i].limit->value,iTable);
+	bp1.setTarget(target);
+	if (!bp1.turnBypass(ts))
 	  conditions[i].source->flags &= ~FLAGS_EVALUATE;
-
 	break;
       }
     }
   }
 }
-
-
-
-int turnBypass(int bno,time_t ts,float requested)
-{
-  int ret=1;
-  float diff;
-  long turntime;
-
-  bypasses[bno].targetAd=requested;
-  if (bypasses[bno].actualTemp->measured.analog==-273) return ret;
-
-  diff = requested - bypasses[bno].actualTemp->measured.analog;
-  turntime=abs(diff) * bypasses[bno].timeMultiplier;
-  Serial.print(" diff is ");
-  Serial.println(diff);
-  bypasses[bno].changed=ts;
-  if (turntime > bypasses[bno].maxTurntime)
-    turntime=bypasses[bno].maxTurntime;
-  else if (turntime < bypasses[bno].minTurntime)
-    turntime=bypasses[bno].minTurntime;
-
-  if (diff > bypasses[bno].hysteresis)
-    sched.oscillate(bypasses[bno].up,turntime,LOW,1);
-  else if (diff < (-1.0 * bypasses[bno].hysteresis))
-    sched.oscillate(bypasses[bno].dn,turntime,LOW,1);
-  else
-    ret=0;
-  return ret;
-}
-
 
 /* find boundings from conversion table
  * and convert / interpolate according to the table

struct condition conditions[]= {
  {0,&adArr[0],&variables[0],&variables[1],&outIoArr[0], 0,METHOD_TURNON},       // start boiler if it is under 24.5, and off when it has reached 26.0
  {1,&adArr[2],&variables[3],&variables[0],&variables[2],0,METHOD_CHANGELIMIT},  // if hothousewater is under hhboil, then boilTemp should be boilReduced.
  {2,&adArr[1],&variables[5],&variables[4],radiatorTab,  0,METHOD_TABLE}        // changes in ambient will change radiatorReq with the help of radiatorAdd variable and radiatorTab table.
};



  _counters[1]++;
}

bypassValve::bypassValve(char *name,float *actual,int up,int dn,int timeMultiplier,int latency,float sensitivity,int minTurnTime,int maxTurnTime) {
  _name=name;
  _actualTemp=actual;
  _up=up;
  _dn=dn;
  _timeMultiplier=timeMultiplier;
  _latency=latency;
  _changed=0;
  _sensitivity=sensitivity;
  _minTurnTime=minTurnTime;
  _maxTurnTime=maxTurnTime;
  _targetTemp=-273;
}

void bypassValve::setTarget(float val) {
  _targetTemp=val;
}

int bypassValve::turnBypass(time_t ts) {
  int ret=1;
  float diff;
  long turntime;

  if (*_actualTemp==-273) return ret;

  if ((ts - _changed) > _latency-1)
    _changed =ts;
  else {
    return ret;
  }

  diff = _targetTemp - *_actualTemp;
  turntime=abs(diff) * _timeMultiplier;
  Serial.print(" diff is ");
  Serial.println(diff);

  if (turntime > _maxTurnTime)
    turntime=_maxTurnTime;
  else if (turntime < _minTurnTime)
    turntime=_minTurnTime;

  if (diff > _sensitivity)
    sched.oscillate(_up,turntime,LOW,1);
  else if (diff < (-1.0 * _sensitivity))
    sched.oscillate(_dn,turntime,LOW,1);
  else
    ret=0;
  return ret;
}

int resetVariable(char *name)
{
