diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp
index 8cfc51ef5..209e76fa8 100644
--- a/src/libslic3r/GCode/GCodeProcessor.cpp
+++ b/src/libslic3r/GCode/GCodeProcessor.cpp
@@ -170,7 +170,7 @@ void GCodeProcessor::TimeMachine::reset()
     prev.reset();
     gcode_time.reset();
     blocks = std::vector<TimeBlock>();
-    g1_times_cache = std::vector<float>();
+    g1_times_cache = std::vector<G1LinesCacheItem>();
     std::fill(moves_time.begin(), moves_time.end(), 0.0f);
     std::fill(roles_time.begin(), roles_time.end(), 0.0f);
     layers_time = std::vector<float>();
@@ -292,7 +292,7 @@ void GCodeProcessor::TimeMachine::calculate_time(size_t keep_last_n_blocks)
             }
             layers_time[block.layer_id - 1] += block_time;
         }
-        g1_times_cache.push_back(time);
+        g1_times_cache.push_back({ block.g1_line_id, time });
     }
 
     if (keep_last_n_blocks)
@@ -398,14 +398,18 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename)
     auto process_line_G1 = [&]() {
         for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedTimeStatistics::ETimeMode::Count); ++i) {
             const TimeMachine& machine = machines[i];
-            if (machine.enabled && g1_lines_counter < machine.g1_times_cache.size()) {
-                float elapsed_time = machine.g1_times_cache[g1_lines_counter];
-                std::pair<int, int> to_export = { int(100.0f * elapsed_time / machine.time),
-                                                  time_in_minutes(machine.time - elapsed_time) };
-                if (last_exported[i] != to_export) {
-                    export_line += format_line_M73(machine.line_m73_mask.c_str(),
-                        to_export.first, to_export.second);
-                    last_exported[i] = to_export;
+            if (machine.enabled) {
+                auto it = std::find_if(machine.g1_times_cache.begin(), machine.g1_times_cache.end(),
+                    [g1_lines_counter](const TimeMachine::G1LinesCacheItem& item) { return item.id == g1_lines_counter; });
+                if (it != machine.g1_times_cache.end()) {
+                    float elapsed_time = it->elapsed_time;
+                    std::pair<int, int> to_export = { int(100.0f * elapsed_time / machine.time),
+                                                      time_in_minutes(machine.time - elapsed_time) };
+                    if (last_exported[i] != to_export) {
+                        export_line += format_line_M73(machine.line_m73_mask.c_str(),
+                            to_export.first, to_export.second);
+                        last_exported[i] = to_export;
+                    }
                 }
             }
         }
@@ -713,6 +717,7 @@ void GCodeProcessor::reset()
 
     m_filament_diameters = std::vector<float>(Min_Extruder_Count, 1.75f);
     m_extruded_last_z = 0.0f;
+    m_g1_line_id = 0;
     m_layer_id = 0;
     m_cp_color.reset();
 
@@ -1395,6 +1400,8 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
         return type;
     };
 
+    ++m_g1_line_id;
+
     // enable processing of lines M201/M203/M204/M205
     m_time_processor.machine_envelope_processing_enabled = true;
 
@@ -1500,6 +1507,7 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
         block.move_type = type;
         block.role = m_extrusion_role;
         block.distance = distance;
+        block.g1_line_id = m_g1_line_id;
         block.layer_id = m_layer_id;
 
         // calculates block cruise feedrate
diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp
index 884450e98..8f0c26cf5 100644
--- a/src/libslic3r/GCode/GCodeProcessor.hpp
+++ b/src/libslic3r/GCode/GCodeProcessor.hpp
@@ -145,6 +145,7 @@ namespace Slic3r {
 
             EMoveType move_type{ EMoveType::Noop };
             ExtrusionRole role{ erNone };
+            unsigned int g1_line_id{ 0 };
             unsigned int layer_id{ 0 };
             float distance{ 0.0f }; // mm
             float acceleration{ 0.0f }; // mm/s^2
@@ -182,6 +183,12 @@ namespace Slic3r {
                 void reset();
             };
 
+            struct G1LinesCacheItem
+            {
+                unsigned int id;
+                float elapsed_time;
+            };
+
             bool enabled;
             float acceleration; // mm/s^2
             // hard limit for the acceleration, to which the firmware will clamp.
@@ -193,7 +200,7 @@ namespace Slic3r {
             State prev;
             CustomGCodeTime gcode_time;
             std::vector<TimeBlock> blocks;
-            std::vector<float> g1_times_cache;
+            std::vector<G1LinesCacheItem> g1_times_cache;
             std::array<float, static_cast<size_t>(EMoveType::Count)> moves_time;
             std::array<float, static_cast<size_t>(ExtrusionRole::erCount)> roles_time;
             std::vector<float> layers_time;
@@ -376,6 +383,7 @@ namespace Slic3r {
         ExtruderColors m_extruder_colors;
         std::vector<float> m_filament_diameters;
         float m_extruded_last_z;
+        unsigned int m_g1_line_id;
         unsigned int m_layer_id;
         CpColor m_cp_color;