   delay(1000);
 }
 
-void sendMessage(String msg)
-{
+void sendMaster(String msg)
+{
+  bt.begin(9600);
+  bt.flush();
   if(debug == true) {Serial.print("sending Bluetooth message: "); Serial.println(msg);}
-  bt.flush();
-  // Serial.print("Sending message: ");
-  //Serial.println(message);
   bt.println(msg);
+  bt.end();
 }
 
 void readMaster()
 {
-  if(debug == true) {Serial.println("reading Master Bluetooth...");}
+  bt.begin(9600);
   if (bt.available() > 0) {
     String msg; // string to store entire command line
+    if(debug == true) {Serial.println("reading Master Bluetooth...");}
     while (bt.available()) {
-      msg += bt.read();
+      str = bt.read();
+      msg += str;
     }
     Serial.println(msg);
     delay(50);

    }
    Serial.println(msg);
    delay(50);
    sendMessage(msg);
    } else {
      if(debug == true) {Serial.println("nothing from OBD Bluetooth.");}
      sendMessage("No data from OBD2.");
  }
  obd.flush();
}

void readGPS()
{
  if(debug == true) {Serial.println("reading GPS...");}
  // This sketch displays information every time a new sentence is correctly encoded.
  if (ss.available() > 0) {
    //delay(1000); // wait 1 sec to give time enough for the serial to receive all the stream
    while (gps.encode(ss.read())) {
      displayInfo();
    }
  } else {
    if(debug == true) {Serial.println("nothing from GPS.");}
  }
  ss.flush();

  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    if(debug == true) {Serial.println("No GPS detected: check wiring.");}

  } else {
    if(debug == true) {Serial.println("nothing from Master Bluetooth.");}
  }
  //bt.flush();
  bt.end();
}

void readOBD()
{
  if (obd.available() > 0) {
    if(debug == true) {Serial.println("reading OBD Bluetooth...");}
    String msg; // string to store entire command line
    delay(1000); // wait 1 sec to give time enough for the serial to receive all the stream
    while (obd.available()) {
