       prevFlag = cur;
       pivotFlag = false;
       pastNear = false;
-    } else if ((cur - prevIR) >= 25) {
+    } 
+  if ((cur - prevIR) >= 25) {
       // otherwise, poll all the distance sensors
       prevIR = cur;
       rightDist = sensor.getDist();

bool prevHallL;
int arrPosR; //pointer to insert values in the speed array
int arrPosL;

// thresholds for distance sensors
int near = 200;

      perLeftDist = sideleft.getDist();

      //attack code with sensors
      if (expectedVelL > gelVelL() + hallTimeThresh || expectedVelR > getVelR() + hallTimeThresh) {
        if (!pastStalled){
          stalled = cur;
          pastStalled = true;
        } else if (cur - stalled > stallThresh) {
          state = 12;
          pivotFlag = true;
        }   
      } else if (pastStalled) {
        pastStalled = false;
      }

      if (!pivotFlag) { // first check if the robot hasn't pivoted in the past (if it has, don't do any of the actions below)
        if (past == 'f' && pastNear && attackCount < 100) {
