     String buffer = "";
     buffer.reserve(10);
     String buffer2 = "";
+    String decomposedMessage[7];
+    for(int i = 0; i<7; i++)
+    {
+      decomposedMessage[i].reserve(10);
+      decomposedMessage[i] = "";
+    }
+      
     buffer2.reserve(10);
     String bufferMotor = "";
     bufferMotor.reserve(10);
     for (int i=0; i<spaceBar; i++)
       buffer += inputString.charAt(i);
 
+    for(int indexPtr = 0, segmentPtr = 0; indexPtr<(inputString.length()-1) && segmentPtr<7; indexPtr++)
+    {
+      decomposedMessage[segmentPtr] +=  inputString.charAt(indexPtr);
+      if(inputString.charAt(indexPtr+1) == ' ')
+      {
+        segmentPtr++; 
+        indexPtr++;
+      }
+    }
+
 //    spaceBar = inputString.indexOf(' ');
-    for (int i=spaceBar+1; i<(inputString.length()-1); i++)
-      buffer2 += inputString.charAt(i);
-      
-    if (buffer == "Set" || buffer == "SetSpeed")
+//    for (int i=spaceBar+1; i<(inputString.length()-1); i++)
+//      buffer2 += inputString.charAt(i);
+
+    if(decomposedMessage[0] == "Set")
     {
-      spaceBar = buffer2.indexOf(' ');
-      for (int i=spaceBar+1; i<(buffer2.length()); i++)
-        bufferMotor += buffer2.charAt(i);
- 
-      Serial.println("Set command detected!");
-      if(bufferMotor=="motor1"){
-      u[0]= buffer2.toInt();
-      if (u[0]>mios)
-          u[0] = mios;
-      else if (u[0]<-mios)
-          u[0]= -mios;
-        
-      e1 = u[0]-v1;
+      timeOfLastMessageReceived = millis();
+      for (int i=0; i<6; i++)
+      {
+        int buffer = decomposedMessage[i+1].toInt();
+        if(buffer > 0)
+          u[i] = min(buffer, mios);
+        else
+          u[i] = max(buffer, -mios);
       }
-      else if(bufferMotor=="motor2"){
-      u[1]= buffer2.toInt();
-      if (u[1]>mios)
-          u[1]= mios;
-      else if (u[1]<-mios)
-          u[1]= -mios;
-        
-      e2 = u[1]-v2;
+
+      for (int i=0; i<6; i++)
+      {
+        Serial.print(u[i]);
+        Serial.print(", ");
       }
-      else if(bufferMotor=="motor3"){
-       u[2]= buffer2.toInt();
-      if (u[2]>mios)
-          u[2]= mios;
-      else if (u[2]<-mios)
-          u[2] = -mios;
-        
-      e3 = u[2]-v3;
-      }
-      else if(bufferMotor=="motor4"){
-       u[3]= buffer2.toInt();
-      if (u[3]>mios)
-          u[3]= mios;
-      else if (u[3]<-mios)
-          u[3]= -mios;
-        
-      e4 = u[3]-v4;
-      }
-      else if(bufferMotor=="motor5"){
-       u[4]= buffer2.toInt();
-      if (u[4]>mios)
-          u[4]= mios;
-      else if (u[3]<-mios)
-          u[4]= -mios;
-      }
-      else if(bufferMotor=="motor6"){
-       u[5]= buffer2.toInt();
-      if (u[5]>mios)
-          u[5]= mios;
-      else if (u[5]<-mios)
-          u[5]= -mios;
-      }
-      else if(bufferMotor="all")
-      {
-        int uForAll = buffer2.toInt();
-        if (uForAll > mios)
-          uForAll = mios;
-        else if (uForAll < -mios)
-          uForAll = -mios;
-
-        for(uint8_t i = 0; i<6; i++)
-          u[i] = uForAll;
-          
-      }
-      
-      
-      SmartDrive = 1;
+      Serial.println("");
     }
+
     else if (buffer == "SetKp")
     {
       Kp = buffer2.toInt();

      SetSpeed(motor5, u[4]);
      SetSpeed(motor6, u[5]);

      delay(2000);
      for(int i=0; i<6; i++)
      {
      Serial.print(u[i]);
      Serial.print("   ");
      }
      Serial.println("zeroing...");
      u[0]=0;
      u[1]=0;
      u[2]=0;
      u[3]=0;
      u[4]=0;
      u[5]=0;
      

  }

int PWMSpeed[6] = {0, 0, 0, 0, 0, 0};
boolean slopeRise1 = 1, slopeFall1 = 0, slopeRise2 = 1, slopeFall2 = 0, slopeRise3 = 1, slopeFall3 = 0, slopeRise4 = 1, slopeFall4 = 0;
byte timeCounter = 0;
volatile unsigned int timeOfLastMessageReceived = 0;
unsigned long startingTime = 0;
int slopeCounter1 = 0, slopeCounter2 = 0, slopeCounter3 = 0, slopeCounter4 = 0;
byte Kp = 0;
