diff --git a/Simulation.cpp b/Simulation.cpp
index 31ddfbe4e07a121818ab31349994797f0451395d..036a278b2b61dc4f49aab350d7769fb0441fb7f5 100644
--- a/Simulation.cpp
+++ b/Simulation.cpp
@@ -501,7 +501,10 @@ int Simulation::RunBody(double maxSimTime)
      _nPeds = _building->GetAllPedestrians().size();
      int initialnPeds = _nPeds;
      // main program loop
-     while ( (_nPeds || !_agentSrcManager.IsCompleted() ) && t < maxSimTime)
+
+     while ( (_nPeds > 0 || (!_agentSrcManager.IsCompleted() && (_hybridSimManager != nullptr))) && t < maxSimTime)
+     //while ( _nPeds && t < maxSimTime)
+
      {
           t = 0 + (frameNr - 1) * _deltaT;