         // avoid polling millis too often
         for (int i=0; i<10; i++) onestep(pulse);
     }
-    for (int i=0; i<(accelSteps - (decelDiff * recentre)); i++) {
+    for (int i=0; i<accelSteps; i++) {
         onestep(map(i, 0, accelSteps, pulse, startstoppulse));
+        if (i>(accelSteps - (decelLook * recentre) && digitalRead(sensorPin))) break;
     }
     if (recentre) findsensor(startstoppulse);
     digitalWrite(LED_BUILTIN, LOW);

    for (int i=0; i<fullspeedsteps; i++) {
        onestep(pulse);
    }
    for (int i=0; i<(localAccelSteps - decelDiff); i++) {
        onestep(map(i, 0, localAccelSteps, pulse, maxPulse));
    }
    findsensor(maxPulse);
    digitalWrite(LED_BUILTIN, LOW);


// speeds
#define pulseWidth      5
#define halfTurnSteps 200 // steps for a half turn
#define accelSteps     90 // number of steps accelerating
#define decelLook      10 // start looking for sensor this many steps early
#define minPulse      500
#define maxPulse     2300
#define durationGlissCompensation 480
