diff --git a/src/qsched.c b/src/qsched.c
index d816baf957b206134cdc158ac1fe5b5f21a076ec..1cdf53ae29d5ce7c86264d050fd1cb90a9f874cd 100644
--- a/src/qsched.c
+++ b/src/qsched.c
@@ -2409,8 +2409,7 @@ for(i = 0; i < count; i++)
     /*Find the parents. */
     num_parents = 0;
     int max = wait_init[gettaskindex(t->id, s)];
-//    for(j = i-1; j >= 0 && num_parents < max; j--)
-    for(j = 0; j < i && num_parents < max; j++)
+    for(j = i-1; j >= 0 && num_parents < max; j--)
     {
         const struct task *t2 = &s->tasks[gettaskindex(tid[j], s)];
         const int nr_un = t2->nr_unlocks;