     }
     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

      }
    }
  }
}

// Index of the broadest open horizon.


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

int  measurements[stepsInFullTurn];
int  currentIndex = 0;
