     }
   }
 
-  if (isMutuallyExclude){
-   mutuallyExcludePair(switchState, posInArray);
+  if (isMutuallyExclude) {
+    mutuallyExcludePair(switchState, posInArray);
   }
   switchRelay(switchState, posInArray);
 


/*
 * MQTT 32 output pins for driving 2 16-channel relay boards on an arduino mega with ethernet shield.
 * 
 * NOTE: the topic is hardcoded: domogik/in/relay/r + relay number : e.g
 * 
 * mosquitto_pub -t domogik/in/relay/r1 -m 1  -> turn on
 * mosquitto_pub -t domogik/in/relay/r1 -m 0  -> turn off
 * mosquitto_pub -t domogik/in/relay/r1 -m 2  -> toggle; so turn on again
 * 
  By Jeroen Schaeken
  Derived from http://www.esp8266.com/viewtopic.php?f=29&t=8746
  
  It connects to an MQTT server then:
  - on 0 switches off relay
  - on 1 switches on relay

void switchRelay(char* switchState, int pos) {
  // Switch on the LED if an 1 was received as first character
  if (switchState == '0') {
    digitalWrite(relayPins[pos], HIGH);
    relayStates[pos] = HIGH;
    EEPROM.update(pos, relayStates[pos]);    // Write state to EEPROM
  } else if (switchState == '1') {
    digitalWrite(relayPins[pos], LOW);
    relayStates[pos] = LOW;
    EEPROM.update(pos, relayStates[pos]);    // Write state to EEPROM
  }
}

void publishRelayState(int relayNbr, char* state) {
  char outputTopicBuff[100];
  strcpy(outputTopicBuff, outRelayTopic);
  char relaybuffer[5];
  sprintf(relaybuffer, "%d", relayNbr);
  strcat(outputTopicBuff, relaybuffer);
  client.publish(outputTopicBuff, state);
}

void mutuallyExcludePair(char* switchState, int pos) {
  if (pos % 2 == 0 && switchState == '1') //even
  {
    if (pinCount > (pos + 1) && relayStates[pos + 1] == LOW) {
      switchRelay('0', pos + 1);
      publishRelayState(pos + 2, "0");
    }
  }
  else if (pos % 2 == 1 && switchState == '1') //odd
  {
    if ((pos - 1) >= 0 && relayStates[pos - 1] == LOW) {
      switchRelay('0', pos - 1);
      publishRelayState(pos, "0");
    }
  }
}

void callback(char* topic, byte* payload, unsigned int length) {
