   
 // run motors
   bool is_one_motor_running = false;
-  for (int m = 0; m < num_motors; m++)
-    if (motor_control.steppers[m]->distanceToGo()){
-      motor_control.steppers[m]->run();
+  for (int m = 0; m < motors_control.num_motors; m++)
+    if (motors_control.steppers[m]->distanceToGo()){
+      motors_control.steppers[m]->run();
       is_one_motor_running = true;
     }
     else{
-      motor_control.steppers[m]->setCurrentPosition(0);
+      motors_control.steppers[m]->setCurrentPosition(0);
     }
   if (!is_one_motor_running)
     is_command_running = 0;

//--------------------------------------------------------------------------------------------
void setup() 
{
  motor_control.reset_pins();

  Serial.begin(9600); //Open Serial connection
  

              if (current_buffer[i] == 'M' || current_buffer[i] == 'm'){// moves motor
                int motor_index, num_steps;
                sscanf(tmp_str, "%d%d", &motor_index, &num_steps);
                motors_control.move_motor(motor_index, num_steps);
                is_command_running = 1;
              }
              else
                if (current_buffer[i] == 'D' || current_buffer[i] == 'd'){// disables motor
                  int motor_index;
                  sscanf(tmp_str, "%d", &motor_index);
                  motors_control.disable_motor(motor_index);
                }
                else
                  if (current_buffer[i] == 'L' || current_buffer[i] == 'l'){// locks motor
                    int motor_index;
                    sscanf(tmp_str, "%d", &motor_index);
                    motors_control.lock_motor(motor_index);
                  }
                else
                  if (current_buffer[i] == 'U' || current_buffer[i] == 'u'){// ultrasonic
                      Serial.print(ultrasonic.Ranging());
                  }
                else
                  if (current_buffer[i] == 'S' || current_buffer[i] == 's'){// motor speed
                    int motor_index, motor_speed;
                    sscanf(tmp_str, "%d%d", &motor_index, &motor_speed);
                    motors_control.set_motor_speed(motor_index, motor_speed);
                  }
                else
                  if (current_buffer[i] == 'A' || current_buffer[i] == 'a'){// motor acceleration
                    int motor_index, motor_acceleration;
                    sscanf(tmp_str, "%d%d", &motor_index, &motor_acceleration);
                    motors_control.set_motor_acceleration(motor_index, motor_acceleration);
                  }
                    
              // remove the current executed command
