   {
     index = adcMax;
   }
-  int temperature = pgm_read_word(&temperatureTable[index]);
-  return double(temperature)/10;
+  int lookup = pgm_read_word(&temperatureTable[index]);
+  temperature = double(lookup)/10.0;
 }
 
 int temperatureToInt(double temperature) {
-  return int(10*temperature);
+  return int(round(10*temperature));
 }
 
 unsigned long windowStartTime;

  cmdMessenger.feedinSerialData();
  
  if (currentMillis - previousMillis > 100) {
    temperaturePID.Compute();
    controlHeater();
    temperature = measureTemperature();
    previousMillis = currentMillis;
    slowCount++;
    if (slowCount > 50) {
      Serial << STATMSG << "Duty Cycle is " << dutyCycle << ENDMSG;
      slowCount = 0;
    }

double temperature;
double setpoint;
double dutyCycle;
PID temperaturePID(&temperature, &dutyCycle, &setpoint, 50, 0, 0, DIRECT);
  
const int adcSubstract = 51;
const int adcMax = 784;
