         DEBUG_PRINT("[INIT] Sending IR: ");
         DEBUG_PRINTLN(session_id);
         irsend.sendSony(session_id, 16);
-        m = XBeeMode;
+        XBeeReturnCount = 0;
+        start_time = millis();
+        m = WaitMode;
         XBee.begin(9600);
-        // TODO
-        // better wait for a while before ending XBee session
-        //
       }
       else {
         XBee.begin(9600);

      m = BTMode;
    }
  }
  delay(10);
}
  BT.begin(57600);
  delay(300);
  m = BTMode;
  XBeeReturnCount = 0;
  Serial.print("system begins");
}

