           }
         }
         else
-        if (current_buffer[i] == 'D'){// Disables motor command.
-          // find the terminal character #
-          int j = i + 1;
-          for (; j < buffer_length && current_buffer[j] != '#'; j++);// parse until I find the termination char
-          if (j < buffer_length){
+          if (current_buffer[i] == 'D'){// Disables motor
+            // find the terminal character #
+            int j = i + 1;
+            for (; j < buffer_length && current_buffer[j] != '#'; j++);// parse until I find the termination char
+            if (j < buffer_length){
               char tmp_str[64];
               strncpy(tmp_str, current_buffer + i + 1, j - i - 1);
               tmp_str[j - i - 1] = 0;

              // remove the current executed command
              strcpy(current_buffer, current_buffer + j + 1);
              break;
          }
          else{// the string is not completed ... so I must wait more...
            break; // for i
          }
        }
        
    }
  }
  

  digitalWrite(enable_pins[motor_index], HIGH); // disable motor
}
//--------------------------------------------------------------------------------------------
void lock_motor(int motor_index)
{
  digitalWrite(enable_pins[motor_index], LOW); // disable motor
}
//--------------------------------------------------------------------------------------------
//Reset pins to default states
void reset_pins()
{
