diff --git a/src/scheduler.c b/src/scheduler.c
index a71b9016740cbe1f4660351129611aadd498e1fd..795ef9aa8f7e1917efc8d570722c7066c9fef2b0 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -1306,15 +1306,15 @@ void scheduler_reweight(struct scheduler *s, int verbose) {
 
       case task_type_sub_pair:
         if (t->ci->nodeID != nodeID || t->cj->nodeID != nodeID) {
-          if (t->flags < 0)
-            cost = 3.f * (wscale * count_i) * count_j;
-          else
-            cost = 3.f * (wscale * count_i) * count_j * sid_scale[t->flags];
+#ifdef SWIFT_DEBUG_CHECKS
+          if (t->flags < 0) error("Negative flag value!");
+#endif
+	  cost = 3.f * (wscale * count_i) * count_j * sid_scale[t->flags];
         } else {
-          if (t->flags < 0)
-            cost = 2.f * (wscale * count_i) * count_j;
-          else
-            cost = 2.f * (wscale * count_i) * count_j * sid_scale[t->flags];
+#ifdef SWIFT_DEBUG_CHECKS
+          if (t->flags < 0) error("Negative flag value!");
+#endif
+	  cost = 2.f * (wscale * count_i) * count_j * sid_scale[t->flags];
         }
         break;