diff --git a/Applications/ApplicationsLib/Simulation.cpp b/Applications/ApplicationsLib/Simulation.cpp
index 5886a5cb76ceaef1d45a6bcad9efbc09d329e0a8..54cf753c201412896e77e9a8194fc21e0ed92ead 100644
--- a/Applications/ApplicationsLib/Simulation.cpp
+++ b/Applications/ApplicationsLib/Simulation.cpp
@@ -139,7 +139,8 @@ bool Simulation::executeSimulation()
     auto& time_loop = project_data->getTimeLoop();
     while (time_loop.currentTime() < time_loop.endTime())
     {
-        if (!time_loop.executeTimeStep())
+        time_loop.executeTimeStep();
+        if (!time_loop.calculateNextTimeStep())
         {
             break;
         }
diff --git a/ProcessLib/TimeLoop.cpp b/ProcessLib/TimeLoop.cpp
index 188af31216676c19d8f89cf489426b5bf2e4aba4..f066994605a829ea5860af9d91bba386c63be5d1 100644
--- a/ProcessLib/TimeLoop.cpp
+++ b/ProcessLib/TimeLoop.cpp
@@ -548,7 +548,6 @@ bool TimeLoop::executeTimeStep()
     time_timestep.start();
 
     _current_time += _dt;
-    const double prev_dt = _dt;
 
     const std::size_t timesteps = _accepted_steps + 1;
     // TODO(wenqing): , input option for time unit.
@@ -560,7 +559,12 @@ bool TimeLoop::executeTimeStep()
     successful_time_step = doNonlinearIteration(_current_time, _dt, timesteps);
     INFO("[time] Time step #{:d} took {:g} s.", timesteps,
          time_timestep.elapsed());
+    return successful_time_step;
+}
 
+bool TimeLoop::calculateNextTimeStep()
+{
+    const double prev_dt = _dt;
     double const current_time = _current_time;
 
     const std::size_t timesteps = _accepted_steps + 1;
@@ -569,7 +573,7 @@ bool TimeLoop::executeTimeStep()
     std::vector<std::function<double(double, double)>> time_step_constraints{
         [&fixed_times](double t, double dt)
         { return NumLib::possiblyClampDtToNextFixedTime(t, dt, fixed_times); },
-        [&end_time](double t, double dt)
+        [this](double t, double dt)
         {
             if (t < _end_time && t + dt > _end_time)
             {
diff --git a/ProcessLib/TimeLoop.h b/ProcessLib/TimeLoop.h
index 36f76bf2c0aaa95af7f75588e58e041b1ea3d19b..8b6cfaa80e3337d05589c097e9ae0e37862bcd03 100644
--- a/ProcessLib/TimeLoop.h
+++ b/ProcessLib/TimeLoop.h
@@ -49,6 +49,7 @@ public:
     ~TimeLoop();
 
     bool executeTimeStep();
+    bool calculateNextTimeStep();
     double endTime() const { return _end_time; }
     double currentTime() const { return _current_time; }
     bool successful_time_step = false;