Servomotor + Sensor + Timer as a delay

Hello, I'm trying to use timers instead of delays to rotate a servo and then take a distance reading. It rotates moderately well (bit random sometimes) and takes the distance reading but in between the times where the timer has not elapsed, when the code runs back through that function it takes the interval time as the reading for distance.

Is there a way I can save the distance value and keep that value stored until the timer is elapsed and another reading is taken.

Heres a snippet of the code

Setup:

long previousMillis = 0; 
long previousMillis2 = 0;
long previousMillis3 = 0;
long interval = 1000;
long interval2 = 2000;
long interval3 = 3000;
unsigned long currentMillis;

In loop:

  int leftscanval = scanleft();
  Serial.print("leftscanval:  ");
Serial.println(leftscanval);
  int rightscanval = scanright();
  Serial.print("rightscanval:  ");
Serial.println(rightscanval);
  int centerscanval = scancenter();
Serial.print("centerscanval:  ");
Serial.println(centerscanval);

Functions:

int scanleft(){
  long leftscanval;
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis >= interval) {
  scanservo.write(30);
  leftscanval = ping();
  previousMillis = currentMillis;
  Serial.print("leftscanval:  ");
  Serial.println(leftscanval);
    return leftscanval;
  }

}

int scanright(){
  long rightscanval;
  unsigned long currentMillis2 = millis();
  if(currentMillis2 - previousMillis2 >= interval2) {
  scanservo.write(150);
  rightscanval = ping();
  previousMillis2 = currentMillis2;
  Serial.print("rightscanval:  ");
  Serial.println(rightscanval);
     return rightscanval;
   }

}

int scancenter (){
  long centerscanval;  
  unsigned long currentMillis3 = millis();
  if(currentMillis3 - previousMillis3 >= interval3) {
  scanservo.write(90);
  centerscanval = ping();
  previousMillis3 = currentMillis3;;
  Serial.print("centerscanval:  ");
  Serial.println(centerscanval);
  return centerscanval; 
  }
}

I don't think there is any point in commenting without seeing the full sketch.

You have only showed snippets that return values but we have no idea what happens to the returned value.

...R