   } while (preparationF2LReady == false);
 }
 
+
+//Method for solving the OLL
+void solveOLL() {
+   //Check that last layer is already solved. If it is solved, complete the step. If not solved - find a solution.
+  if (ScannedCube[0] == u_color && ScannedCube[1] == u_color && ScannedCube[2] == u_color && ScannedCube[3] == u_color && ScannedCube[5] == u_color
+       && ScannedCube[6] == u_color && ScannedCube[7] == u_color && ScannedCube[8] == u_color) {
+        solving_level = 4;
+        Serial.print(F("OLL solved"));
+   }
+      
+   else {
+       defineOLLsequence(); 
+   }
+}
+
+//Method for defining the OLL solution sequence
+void defineOLLsequence() {
+  byte index;
+  //Counter for controlling the number of u-moves
+  byte uTurnCount = 0;
+  //Flag showing that solution was found
+  boolean ollSequenceFound = false;
+  //Counter for finding the exact solution in solutions char string
+  byte ollPointCounter = 0;
+  //Search for a solution. If solution was not found - make the u-turn
+  while (ollSequenceFound == false && uTurnCount<4) {
+     for (index = 0; index <57; index++) {
+       if (ScannedCube[pgm_read_byte(&(oll_t[index][0]))] == u_color && ScannedCube[pgm_read_byte(&(oll_t[index][1]))] == u_color && 
+           ScannedCube[pgm_read_byte(&(oll_t[index][2]))] == u_color && ScannedCube[pgm_read_byte(&(oll_t[index][3]))] == u_color && 
+           ScannedCube[pgm_read_byte(&(oll_t[index][4]))] == u_color && ScannedCube[pgm_read_byte(&(oll_t[index][5]))] == u_color &&
+           ScannedCube[pgm_read_byte(&(oll_t[index][6]))] == u_color && ScannedCube[pgm_read_byte(&(oll_t[index][7]))] == u_color) {
+              ollSequenceFound = true;
+              break;
+            }
+        }
+      
+      if (ollSequenceFound == false) {
+        virtualMove('u');
+        uTurnCount ++;
+      }
+  }
+
+  Serial.print(F("OLL sequence #: "));
+  Serial.println(index);
+  
+  //Find a solution string in solutions char array
+  if (index < 57 && uTurnCount < 4) {
+      for (int k = 0; k<1000; k++) { 
+          //Find the current dot separator number
+          if (pgm_read_byte(&(oll_solutions[k])) == '.') {
+            ollPointCounter ++;
+            }
+          //Perform the move if the needed solution was obtained
+          if (ollPointCounter == index && pgm_read_byte(&(oll_solutions[k])) != '.') {
+            virtualMove(pgm_read_byte(&(oll_solutions[k])));
+            }
+          //Stop as soon as the ending dot was found
+          else if (ollPointCounter > index) {
+            break;
+            }
+          }
+       }   
+  else {
+     Serial.println(F("Error in OLL"));
+  }
+
+}
+

  defineSideColors();
  solving_level = 1;
  stage_solving_step = 0;
  while(solving_level != 3) {
    solveStage();
  }
  lcd.clear();


    case 2:
      solveF2L();
      break;

    case 3:
      solveOLL();
      break;
    
  }
