double maxspeed;
   Segment *hindmost, *furthest, *desire_move;
   int desire_movposcomb;
-  int lookahead;
+  int lookahead, reportcount;
 
   PredictionProblemCallback *problem_callback;
   void *problem_callback_u;
   char flags[6];
   int r;
 
-  u->lookahead++;
-  if (u->lookahead > NUM_SEGMENTS * 2) {
+  u->reportcount++;
+  if (u->reportcount > NUM_SEGMENTS * 2) {
     ouprintf(" [... infinite loop!]\n");
     abort();
   }
 
   if (u->done_fdet) /* we've had foredetect */
-    if (u->lookahead > u->train->plan_lookahead_nsegs)
+    if (++u->lookahead > u->train->plan_lookahead_nsegs)
       return -1;
 
   flags[0]= 0;