     
     //Handle Transmitter Temperature
     if (temperature_tx_average >= TEMP_TX_LIMIT_HIGH){
-      digitalWrite(RELAIS_12V, LOW);
+      overTemperatureTx = true;  //needed to ensure that ADC doesn't enable the 12V again
       relais_12v = false;
-      overTemperatureTx = true;  //needed to ensure that ADC doesn't enable the 12V again
     }
     if (temperature_tx_average <= TEMP_TX_LIMIT_LOW){
       overTemperatureTx = false;
-      if ((overTemperatureCabinet == false) && (error_12v == false)){
-        digitalWrite(RELAIS_12V, HIGH);
-        relais_12v = true;
-      }
+      setRelais12v(true);
     }
 
     //Handle Cabinet Temperature
     if (temperature_cabinet_average >= TEMP_CABINET_LIMIT_HIGH){
-      digitalWrite(RELAIS_12V, LOW);
-      relais_12v = false;
       overTemperatureCabinet = true;  //needed to ensure that ADC doesn't enable the 12V again
+      setRelais12v(false);
     }
     if (temperature_cabinet_average <= TEMP_CABINET_LIMIT_LOW){
       overTemperatureCabinet = false;
-      if ((overTemperatureTx == false) && (error_12v == false)){
-        digitalWrite(RELAIS_12V, HIGH);
-        relais_12v = true;
-      }
+      setRelais12v(true);
     }
   }
   else{

  //substract the last reading  
  adc_12v_total -= adc_12v[adc_index];
  adc_5v_total -= adc_5v[adc_index];
  adc_swr_front_total -= adc_swr_front[adc_index];
  adc_swr_back_total -= adc_swr_back[adc_index];
  
  adc_12v[adc_index] = analogRead(ADC_12V);
  adc_5v[adc_index] = analogRead(ADC_5V);
  adc_swr_front[adc_index] = analogRead(ADC_SWR_FRONT);
  adc_swr_back[adc_index] = analogRead(ADC_SWR_BACK);
  
  adc_12v_total += adc_12v[adc_index];
  adc_5v_total += adc_5v[adc_index];
  adc_swr_front_total += adc_swr_front[adc_index];
  adc_swr_back_total += adc_swr_back[adc_index];

  Serial.println(adc_12v[adc_index]);

  adc_index +=1; 
  
  if (adc_index >= ADC_READINGS){
    adc_index = 0;
  }
  
  adc_12v_average = adc_12v_total / ADC_READINGS;
  adc_5v_average = adc_5v_total / ADC_READINGS;
  adc_swr_front_average = adc_swr_front_total / ADC_READINGS;
  adc_swr_back_average = adc_swr_back_total / ADC_READINGS;

}
  


//******************************************************************

// Counters
int irq_temp_counter = 0; //pre-scaler for Timer1 -> temperature measurement routine
int irq_led_blink_counter = 0; //pre-scaler for Timer1 -> status LED blinking
int irq_swr_counter = 0; //pre-scaler for Timer1 -> SWR Measurement


//******************************************************************
