diff --git a/agui2/src/Execution/ParallelExecutor.cpp b/agui2/src/Execution/ParallelExecutor.cpp
index a5cc8e5d24dd2e3d903dda30505277f8c9456a6a..cc616c34601c9964a3c08dbe17754ee150ab5908 100644
--- a/agui2/src/Execution/ParallelExecutor.cpp
+++ b/agui2/src/Execution/ParallelExecutor.cpp
@@ -12,32 +12,18 @@
 
 std::shared_ptr<abstraction::OperationAbstraction> ParallelExecutor::execute(OutputModelBox* output) {
 
-    for (auto* box: ModelBox::getAllModelBoxes()) {
-        box->id = static_cast<size_t>(-1);
-        box->level = static_cast<size_t>(-1);
-        box->clearCachedResult();
-    }
-
-    // collect all boxes leading to the output box
-    std::vector<ModelBox*> boxes;
-    boxes.push_back(output);
+    const std::vector<ModelBox*>& boxes = ModelBox::getAllModelBoxes();
 
     for (size_t i = 0; i < boxes.size(); ++i) {
-        ModelBox* box = boxes[i];
-        if (box->id != static_cast<size_t>(-1)) {
-            // cycle detected
-            throw exception::CommonException { "Connection graph contains a cycle." };
-        }
-        box->id = i;
-
-        for (auto* b: box->inputs) {
-            if (!b) {
-                // unconnected input
-                // TODO check this earlier
+        auto* box = boxes[i];
+        for (auto* input: box->inputs) {
+            if (!input) {
                 throw exception::CommonException { "Connection graph contains an unconnected input." };
             }
-            boxes.push_back(b);
         }
+        box->id = i;
+        box->level = static_cast<size_t>(-1);
+        box->clearCachedResult();
     }
 
     std::vector<std::vector<size_t>> M;
@@ -50,6 +36,9 @@ std::shared_ptr<abstraction::OperationAbstraction> ParallelExecutor::execute(Out
     for (size_t i = 0; i < N; ++i) {
         ModelBox* b = boxes[i];
         for (const auto& neighbour: b->outputs) {
+            if (b == neighbour.first) {
+                throw exception::CommonException { "Connection graph contains a loop." };
+            }
             M[b->id][neighbour.first->id] = 1;
         }
     }
@@ -122,7 +111,9 @@ std::shared_ptr<abstraction::OperationAbstraction> ParallelExecutor::execute(Out
 
     for (size_t i = 0; i < N; ++i) {
         for (size_t j = 0; j < N; ++j) {
-            Q_ASSERT(!M[i][j]);
+            if (M[i][j]) {
+                throw exception::CommonException { "Connection graph contains a cycle." };
+            }
         }
     }