Arduino Slow response

Hi iam making a line following robot using a arduino uno,l298N motor driver and three IR sensors that that outputs HIGH or LOW.
this is the first state in wich i start the robot irL==1 && irM==0 && irR==1
but when the robot moves and the State changes to irL==0 && irM==0 && irR==1 the robot takes about 5 seconds to change its direction so it has already missed the line.

here is the code iam using.

arduino_forums.ino (2.11 KB)

int mr1=2; //motor right 1
int mr2=3; //motor right 2
int mL1=4;  //motor left 1
int mL2=5;  //motor left 2

void setup() {
   pinMode (mr1,OUTPUT);
  pinMode (mr2,OUTPUT);
  pinMode (mL1,OUTPUT);
  pinMode (mL2,OUTPUT);
 pinMode (A2,INPUT);
  pinMode (A1,INPUT);
  pinMode (A0,INPUT);
  pinMode (A3,INPUT);
  Serial.begin(115200);
}

void loop() {
  int irL=digitalRead (A2); // ir sensor left
int irM=digitalRead(A1);   //ir sensor middle 
int irR=digitalRead(A0);  // ir sensor right 

if(irL==1 && irM==0 && irR==1){
    digitalWrite(mr1,HIGH);//Right motor in1 high
    digitalWrite(mr2,LOW);//RIGht motor in2 Low 
    digitalWrite(mL1,HIGH);//Left Motor in1 High
   digitalWrite(mL2,LOW);//Left Motor in2 low
    Serial.println("Forward");
    
  }
  else if (irL==0 && irM==0 && irR==1){
    digitalWrite(mr1,HIGH);// right motor in1 high
   digitalWrite (mr2,LOW); // right motor in2 low 
    digitalWrite (mL1,LOW); // left motor in1 low 
    digitalWrite (mL2,HIGH); // left motor in2 high 
    Serial.println("90 left");
    
  }
  else if (irL==1 && irM==0 && irR==0){
    digitalWrite(mr1,LOW);///right motor in1 Low
  digitalWrite(mr2,HIGH);//right motor in2 HIGH
   digitalWrite(mL1,HIGH);// Left motor in1 High
    digitalWrite(mL2,LOW);//Left motor in2 LOw
    Serial.println("90 right");
 
  }
  else if (irL==1 && irM==1 && irR==0){
    digitalWrite (mr1,LOW); //right motor in1 high 
    digitalWrite (mr2,HIGH);  // right motor in2 low 
    digitalWrite (mL1,HIGH);  // left motor in1 low 
    digitalWrite (mL2,LOW);  // left motor in2 high 
    Serial.println("right");
  
  }
  else if (irL==0 && irM==1 && irR==1){
    digitalWrite (mr1,HIGH); //right motor in1 high 
    digitalWrite (mr2,LOW);  // right motor in2 low 
    digitalWrite (mL1,LOW);  // left motor in1 low 
    digitalWrite (mL2,HIGH);  // left motor in2 high 
    Serial.println("left");
 
  }
  else if(irL==1 && irM==1 &&irR==1){
     digitalWrite(mr1,HIGH);//Right motor in1 high
    digitalWrite(mr2,HIGH);//RIGht motor in2 Low 
    digitalWrite(mL1,HIGH);//Left Motor in1 High
   digitalWrite(mL2,HIGH);//Left Motor in2 low
    Serial.println("Stop");
 
  }


}

(Uncompiled, untested)

const byte mr1=2;
const byte mr2=3;
const byte mL1=4;
const byte mL2=5;

void setup() 
{
  pinMode (mr1,OUTPUT);
  pinMode (mr2,OUTPUT);
  pinMode (mL1,OUTPUT);
  pinMode (mL2,OUTPUT);
  pinMode (A2,INPUT);
  pinMode (A1,INPUT);
  pinMode (A0,INPUT);
  pinMode (A3,INPUT);
  Serial.begin(115200);
}

void loop() 
{
  int dirn = (digitalRead (A2) << 2) | (digitalRead(A1) << 1) | digitalRead(A0);

  switch (dirn)
  {
    case 0b000:
    break;
    
    case 0b001:
      digitalWrite (mr1, HIGH);
      digitalWrite (mr2, LOW); 
      digitalWrite (mL1, LOW);
      digitalWrite (mL2, HIGH);
      Serial.println(F("90 left"));
    break;
  
    case 0b010:
    break;

    case 0b011:
      digitalWrite (mr1, HIGH);
      digitalWrite (mr2, LOW);
      digitalWrite (mL1, LOW);
      digitalWrite (mL2, HIGH);
      Serial.println(F("left"));
    break;

    case 0b100:
      digitalWrite (mr1, LOW);
      digitalWrite (mr2, HIGH);
      digitalWrite (mL1, HIGH);
      digitalWrite (mL2, LOW);
      Serial.println(F("90 right"));
    break;

    case 0b101:
      digitalWrite (mr1, HIGH);
      digitalWrite (mr2, LOW);
      digitalWrite (mL1, HIGH);
      digitalWrite (mL2, LOW);
      Serial.println(F("Forward"));
    break;

    case 0b110:
      digitalWrite (mr1, LOW);
      digitalWrite (mr2, HIGH);
      digitalWrite (mL1, HIGH);
      digitalWrite (mL2, LOW);
      Serial.println(F("right"));
    break;
  
    case 0b111:
      digitalWrite(mr1, HIGH);
      digitalWrite(mr2, HIGH);
      digitalWrite(mL1, HIGH);
      digitalWrite(mL2, HIGH);
      Serial.println(F("Stop"));
    break;
  }
}