   Serial.println();
 
   current_buffer[0] = 0;
+  is_command_running = 0;
 }
 //--------------------------------------------------------------------------------------------
 //Main loop
 void loop() {
   
-  if (Serial.available()) {
+  if (!is_command_running && (Serial.available() || current_buffer[0])) {
     int num_read = 0;
     char arduino_buffer[65];
 
     num_read = Serial.readBytes(arduino_buffer, 64); //Read up to 64 bytes
     arduino_buffer[num_read] = 0;// terminate the string
-    if (num_read){
+    if (arduino_buffer[0] || current_buffer[0]){
       strcat(current_buffer, arduino_buffer);
+      
+      #ifdef DEBUG
+      Serial.write("initial buffer is=");
+      Serial.write(current_buffer);
+      #endif
+      
       // parse from the beginning until I find a M, D, S or A
       int buffer_length = strlen(current_buffer);
       for (int i = 0; i < buffer_length; i++)

  }
  
// run motors
  for (int m = 0; m < num_motors; m++)
    if (steppers[m]->distanceToGo())
      steppers[m]->run();
    else
      steppers[m]->setCurrentPosition(0);
}
//--------------------------------------------------------------------------------------------
void move_motor(int motor_index, int num_steps)

int step_pins[num_motors] = {3,6,9,12};
int enable_pins[4] = {4,7,10,13};

int default_motor_speed = 200; //maximum steps per second 
int default_motor_acceleration = 800; //steps/second/second to accelerate

char is_command_running;

char firmware_version[] = "2015.11.10.6";

AccelStepper *steppers[num_motors];

char current_buffer[65];

#define DEBUG

//--------------------------------------------------------------------------------------------
void setup() 
