     }
     stopMovement(servoLeft, servoRight);
     beep();
-    delay(5000);
+    resetMeasurements();
+    delay(5000);  
   }
+}
+void resetMeasurements(){
+    currentIndex=0;
+    for(int i=0;i<stepsInFullTurn;i++) {measurements[i]=0; noCylinder[i]=false;}
 }
 
 // Determines the index of the best cylinder candidate


const int discardCylDist = 65;
const int horizonDist = 300;

int  measurements[stepsInFullTurn];
int  currentIndex = 0;

  rotateStep(servoLeft, servoRight, counterClockwise);
  int m = measurePingDist();
  
  Serial.println(String(currentIndex)+"\t"+arrayToString(measurements, stepsInFullTurn));
  measurements[currentIndex] = m;
  if(m > discardCylDist){
    noCylinder[currentIndex] = true;
  }
  
  int cyl = -1;
  if(currentIndex >= extraSwipeSteps)
    cyl = findCylinder(currentIndex-extraSwipeSteps);
  if(cyl != -1){
    cyl += extraSwipeSteps;
    Serial.println("found cyl "+String(cyl)+" steps away");
    while(cyl--){
      rotateStep(servoLeft, servoRight, clockwise);
