           if (tmp_str[i] == 'P' || tmp_str[i] == 'p'){// potentiometer            
             int sensor_index;
             sscanf(tmp_str + i + 1, "%d", &sensor_index);
-            Serial.write('P');
-            Serial.print(sensor_index);
-            Serial.write(' ');
-            Serial.print(potentiometers_control.get_position(sensor_index));
-            Serial.write('#');
+            int sensor_value = potentiometers_control.get_position(sensor_index);
+            sprintf(serial_out, "P%d %d#", sensor_index, sensor_value);
             i += 2;
           }
         else
           if (tmp_str[i] == 'U' || tmp_str[i] == 'u'){// ultrasonic
             int sensor_index;
             sscanf(tmp_str + i + 1, "%d", &sensor_index);
-            Serial.write('U');
-            Serial.print(sensor_index);
-            Serial.write(' ');
-            Serial.print(ultrasonic_sensors_controller.getDistanceForSensor(sensor_index));
-            Serial.write('#');
+            int sensor_value = ultrasonic_sensors_controller.getDistanceForSensor(sensor_index);
+            sprintf(serial_out, "U%d %d#", sensor_index, sensor_value);
             i += 2;
           }
         else
           if (tmp_str[i] == 'I' || tmp_str[i] == 'i'){// infrared
             int sensor_index;
             sscanf(tmp_str + i + 1, "%d", &sensor_index);
-            Serial.write('I');
-            Serial.print(sensor_index);
-            Serial.write(' ');
-            Serial.print(infrared_sensors_control.get_distance(sensor_index));
-            Serial.write('#');
+            int sensor_value = infrared_sensors_control.get_distance(sensor_index);
+            sprintf(serial_out, "I%d %d#", sensor_index, sensor_value);
             i += 2;
           }
         else

            int motor_index;
            sscanf(tmp_str + i + 1, "%d", &motor_index);
            motors_control.go_home(motor_index);
          }
          else
          if (tmp_str[i] == 'S' || tmp_str[i] == 's'){ // sets something

                Serial.println();
              #endif

             parse_and_execute_commands(current_buffer + i, j - i, serial_out);
             if (serial_out[0])
               Serial.write(serial_out);
             
                    
              // remove the current executed command
