     }
     
     i=iRight;
+    
+    // When all points have been examined, continue!
+    if(nbrOfRightChecks > stepsInFullTurn){
+      break;
+    }
   }
   
   return iLeftLargest<iRightLargest ? 

long pingDist;
int  measurements[stepsInFullTurn];
int  noCylinder[stepsInFullTurn];

void setup() {
  // initialize serial communication:

  int lenLargest = 0;
  int iLeftLargest = 0;
  int iRightLargest = 0;
  int nbrOfRightChecks = 0;
  //int startIndex = 0; // TODO This variable was unused
  

  int iLeft;
  int iRight;
