Also to help with a case, then b, then select the option to return the case to

When I work, it's usually a case of the loop until the first press made o k = 0, then press the b button and then looping normal functionality similar case a.
But when I returned to press a case, it loops back to the first round, I'm just one more part in the program.

void loop(){
if (Serial.available() > 0) {
 inByte = Serial.read();
   switch (inByte) {
       case 'a':
       while(k){
        loop1();
        check1();}
        break;
  
        
        case 'b':
        grid();
        while(l){
        loop2();
        check2();}
        break;
void check1(){
    if( ch== 'o'){
           k=0;
           l=1;
       
    }
     }
void check2(){
if (Serial.available() > 0) {
char ch2 = Serial.read();
         if( ch2== 'o'){
                 l=0;
                 k=1;
         
      

}
}

Please explain the problem more clearly and post your complete program.

Also, before you post your code, use Ctrl-T in the IDE. This will reformat your code to a more common C coding style and make it easier for us to read.