   for (int i=0; i<NUM_CONN; i++) distanceToSource[i] = 99;
   shortestDistanceToSource = 99;
   alertState = false;
-  
+
   // seed random generator
   randomSeed(analogRead(7));
-  
+
   // start sending energy if we're a source
   if (isSource) addTimer(100, sendEnergy);
-  
+
   if(SERIAL_DEBUG) {
     Serial.begin(9600);
     Serial.println("setup");

  if (isSource) {
    if (!digitalRead(button2pin)) {
      if(SERIAL_DEBUG) Serial.println("alert");
      char c = ALERT; 
      for (int i=0; i<NUM_CONN; i++) bus[i]->write(c);
    }
  }
  
  // check all lines for incoming data
  for (int i=0;i<NUM_CONN;i++) if(bus[i]->available()) {
    char c = bus[i]->read();

  // send out message that we're going to drop a connector
  char c = DROPPING_CONNECTOR;
  for (int i=0; i<NUM_CONN; i++) bus[i]->write(c);

  // pick random connected connector to drop
  // count number of ports with a low distance to source
  int n = 0;
  for (int i=0; i<NUM_CONN; i++) if (distanceToSource[i]<99) n++;
  n = random(1,n+1);
  int i=0;
  // go through ports, only count connecteds ports, untill random number is empty
  while(n) {
    if(distanceToSource[i]<99) n--;
    i++;
  }

  // give communication a break and drop connector
  delay(10);
  digitalWrite(coil[i-1], LOW);
  addTimer(1000, resetConnectors);

  // relax alert state
  alertState = false;
}

// ToDo: why not call this on a fixed interval?
void processEnergy() {
  // assess energy supply, find shortest disance to source
  shortestDistanceToSource = 99;
  for (int i =0; i<NUM_CONN; i++) if (distanceToSource[i] < shortestDistanceToSource) shortestDistanceToSource = distanceToSource[i];

  // if we have energy, switch (or keep) lamp on, pass it on and check again in some time
  if (shortestDistanceToSource<99) {
    if (!lampState) switchLampOn();
    // send shortest distance to ports with a higher distance
    for (int i =0; i<NUM_CONN; i++) if (distanceToSource[i] > shortestDistanceToSource) bus[i]->write(shortestDistanceToSource);
    addTimer(100, processEnergy);
  }
