Multiple LOOPs using NEXTION display

Hello, I have been working with the Nextion display and I have this two programs. One reads temperature and the other just changes led status using 3 buttons on the display

Now the problem is I want to make both the program as one. I need loops of both the program to keep looping until I send an input. I came up with the way:

#include <OneWire.h>
#include <DallasTemperature.h>
#include <Nextion.h>
#include <SoftwareSerial.h>
#include <SD.h>

#define ONE_WIRE_BUS_PIN 2

OneWire oneWire(ONE_WIRE_BUS_PIN);

DallasTemperature sensors(&oneWire);

DeviceAddress Probe01 = { 0x28, 0xFF, 0x31, 0xE3, 0xC2, 0x16, 0x03, 0x78 }; 
DeviceAddress Probe02 = { 0x28, 0xFF, 0xE3, 0xF1, 0xC4, 0x16, 0x04, 0xC8 };

SoftwareSerial nextion(10, 11);

Nextion myNextion(nextion, 9600);
  float tempC1 = 0.0f;
  float tempC2 = 0.0f;
  
int led = 13;

File myFile;
char buf[2];
int led1 = 7;
int led2 = 8;
int led3 = 9;
int inputVariable1 = 1;

 
void setup()   
{
  myNextion.init();
  
  // Initialize the Temperature measurement library
  sensors.begin();
  
  // set the resolution to 10 bit (Can be 9 to 12 bits .. lower is faster)
  sensors.setResolution(Probe01, 10);
  sensors.setResolution(Probe02, 10);
  
  Serial.begin(9600);
  myNextion.init(); // send the initialization commands for Page 0
  
Serial.print("Initializing SD card...");
 /*pinMode(10, OUTPUT);*/
  
 if (!SD.begin(53)) {
   /*Serial.println("initialization failed!");*/
  return;
 }
/* Serial.println("initialization done.");  */
 
}


void loop() 
{
 
  String message = myNextion.listen(); //check for message 
if (message == "65 0 4 0 ffff ffff ffff") {
  ridemode();
   }
   else if (message == "65 0 1 0 ffff ffff ffff"){
     temperature();
   }
}
   

 void temperature(){
    String message = myNextion.listen(); //check for message
      Serial.print(message);
while(message != "65 2 4 0 ffff ffff ffff"){
  String message = myNextion.listen(); //check for message
  sensors.requestTemperatures();  
  
  float tempC1 = sensors.getTempC(Probe01);
  Serial.print(tempC1);
  Serial.println();

  float tempC2 = sensors.getTempC(Probe02);
  Serial.print(tempC2);
  Serial.println(); 
   myNextion.setComponentValue("n0", float(tempC1));  // update text using original sensor value
  delay (100);
   myNextion.setComponentValue("n1", float(tempC2));  // update text using original sensor value
  delay (100);
if ( message == "65 2 4 0 ffff ffff ffff"){
  break;    
  }
}
    
}

 void ridemode() {
    String message = myNextion.listen(); //check for message
      Serial.print(message);
  myFile = SD.open("test.txt");
 if (myFile) {
   while (myFile.available()) {
       myFile.read(buf,2);        
       if(strncmp(&buf[0],"11",2)==0)
       {
       myNextion.sendCommand("b0.picc=0"); //set "b0" image to 2
    myNextion.sendCommand("b1.picc=2");
    myNextion.sendCommand("b2.picc=2");
       }
       else if(strncmp(&buf[0],"22",2)==0)
       {
         myNextion.sendCommand("b1.picc=3");
    myNextion.sendCommand("b0.picc=2");
    myNextion.sendCommand("b2.picc=2");
       }
       else if(strncmp(&buf[0],"33",2)==0)
       {
          myNextion.sendCommand("b2.picc=1");
    myNextion.sendCommand("b0.picc=2");
    myNextion.sendCommand("b1.picc=2");  
       }
       
   }
   // close the file:
   myFile.close();
 }
 

  if (message == "65 1 1 0 ffff ffff ffff") {
    myNextion.sendCommand("b0.picc=0"); //set "b0" image to 2
    myNextion.sendCommand("b1.picc=2");
    myNextion.sendCommand("b2.picc=2");
    SD.remove("test.txt");
    myFile = SD.open("test.txt", FILE_WRITE);
    if (myFile) {
    myFile.println("11");
    myFile.close();
    myNextion.sendCommand("ref b0");
  }
}
  else if (message == "65 1 2 0 ffff ffff ffff") {
    myNextion.sendCommand("b1.picc=3");
    myNextion.sendCommand("b0.picc=2");
    myNextion.sendCommand("b2.picc=2");
    SD.remove("test.txt");
    myFile = SD.open("test.txt", FILE_WRITE);
    if (myFile) {
    myFile.println("22");
    myFile.close();
    myNextion.sendCommand("ref b1");
    } 
  } 
   else if (message == "65 1 3 0 ffff ffff ffff") {
    myNextion.sendCommand("b2.picc=1");
    myNextion.sendCommand("b0.picc=2");
    myNextion.sendCommand("b1.picc=2");
    SD.remove("test.txt");
    myFile = SD.open("test.txt", FILE_WRITE);
    if (myFile) {
    myFile.println("33");
    myFile.close();
    myNextion.sendCommand("ref b2");
    }
  }

   /*else {
 // if the file didn't open, print an error:
   Serial.println("error opening test.txt");
 }*/
 
 myFile = SD.open("test.txt");
 if (myFile) {
   while (myFile.available()) {
       myFile.read(buf,2);        
       if(strncmp(&buf[0],"11",2)==0)
       {
       
           digitalWrite(led1, HIGH);
           digitalWrite(led2, LOW);
           digitalWrite(led3, LOW);
       }
       else if(strncmp(&buf[0],"22",2)==0)
       {
        
   
           digitalWrite(led2, HIGH);
           digitalWrite(led1, LOW);
           digitalWrite(led3, LOW);
       }
       else if(strncmp(&buf[0],"33",2)==0)
       {
           
           digitalWrite(led3, HIGH);
           digitalWrite(led2, LOW);
           digitalWrite(led1, LOW);
       }
       
   }
   // close the file:
   myFile.close();
 }

 
  }

Here the problem is the temperature part, it works, but I need to press the button multiple times for it to read the input. And in the ridemode() part , I cant make it loop at all. Also I want it to stop looping and return to main loop() once I send an input through nextion display.