         if (POTENTIOMETER == type)
         {
             if (0 == potentiometers_control.isWithinLimits(sensor_index))
-            {
               limit_reached = true;
-            }
         }
         else if (ULTRASOUND == type)
         {

      i++;
  }
}

//--------------------------------------------------------------------------------------------
//Main loop
void loop() {

  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 (arduino_buffer[0] || current_buffer[0]){
      strcat(current_buffer, arduino_buffer);
      
      #ifdef DEBUG
        Serial.write("initial buffer is=");

        }
      }

      if (!limit_reached)
      {
        motors_control.steppers[m]->run();
        is_one_motor_running = true;
      }
      else{
        motors_control.steppers[m]->setCurrentPosition(0);
        motors_control.set_motor_running(m, 0);
        Serial.write("M");
        Serial.print(m);
        Serial.write('#');
      }
    }
    else{
      motors_control.steppers[m]->setCurrentPosition(0);
// the motor has just finished the move, so we output that event
      if (motors_control.is_motor_running(m)){
        motors_control.set_motor_running(m, 0);
        Serial.write("M");
        Serial.print(m);
        Serial.write('#');
      }
    }
  }
}

