i'm having trouble with 2 limit switches some help would be really appreciated

Hi evereyone, i'm pretty new in arduino programming and i'm having a hard time writing my own code..i'm building a robotic vacumm cleaner and i basically need it to go straight until one of the limit switches is activated..if the right one is activated i want it to stop,turn and then continue going straight,the same goes for the other switch.Although the code seems correct to me i can't make it work..I'm in need of some help,thank you all in advance
here's the code:

#include <motorshield.h>
#include <Wire.h>
motorshield MotorShield;
int RelayModule=8;
int Lswitch=9;
int Rswitch=10;
int led=13;
#define GND 2
void setup ()
{
MotorShield.initialize();
Serial.begin(9600);
Serial.println("Dual DC Motor Shield test sketch");
pinMode(RelayModule,OUTPUT);
digitalWrite(RelayModule,HIGH);
pinMode(Lswitch, INPUT); 
pinMode(led,OUTPUT);
 
//Setup Channel A
pinMode(6, OUTPUT); //Initiates Motor Channel A pin
 pinMode(9, OUTPUT); //Initiates Brake Channel A pin

 //Setup Channel B
 pinMode(10, OUTPUT); //Initiates Motor Channel A pin
 pinMode(2, OUTPUT);  //Initiates Brake Channel A pi

}
void loop() {

  if  ( (digitalRead (Rswitch) == LOW) and (digitalRead (Lswitch) == LOW) ){
 digitalWrite(RelayModule,LOW);
  digitalWrite(led,HIGH);
  delay(500);
  
  digitalWrite(6, HIGH); //Establishes forward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 255); //Spins the motor on Channel A at FULL speed
  
  digitalWrite(10,HIGH);  //Establishes forward direction of Channel B
  digitalWrite(2, LOW);   //Disengage the Brake for Channel B
  analogWrite(5, 255);    //Spins the motor on Channel B at FULL speed
   
  delay(500);  } 

if ( (digitalRead(Lswitch) == HIGH ) ) { 
  digitalWrite(RelayModule,LOW);
  digitalWrite(led,LOW);
  delay(500);

  
  digitalWrite(9, HIGH);  //Engage the Brake for Channel A
  digitalWrite(2, HIGH);  //Engage the Brake for Channel B

  delay(500);

  digitalWrite(6, LOW); //Establishes backward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 255); //Spins the motor on Channel A at FULL speed
  
  digitalWrite(10,LOW);  //Establishes backward direction of Channel B
  digitalWrite(2, LOW);   //Disengage the Brake for Channel B
  analogWrite(5, 255);    //Spins the motor on Channel B at FULL speed
 
 delay(1000);
 
   digitalWrite(9, HIGH);  //Engage the Brake for Channel A
  digitalWrite(2, HIGH);  //Engage the Brake for Channel B

  delay(500);

  digitalWrite(6,HIGH); //Establishes forward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3,0); //Spins the motor on Channel A at ZERO speed
  
  digitalWrite(10,HIGH);  //Establishes forward direction of Channel B
  digitalWrite(2, LOW);   //Disengage the Brake for Channel B
  analogWrite(5,255);    //Spins the motor on Channel B at FULL speed
 
  Serial.println("if process ended - going to start loop again");
  
  delay(500); }
 
  
  if ( (digitalRead(Rswitch) == HIGH) ) {
  Serial.println("switch just pressed!"); //
  digitalWrite(RelayModule,LOW);
  digitalWrite(led,LOW);

  digitalWrite(9, HIGH);  //Engage the Brake for Channel A
  digitalWrite(2, HIGH);  //Engage the Brake for Channel B

  delay(500);

  digitalWrite(6, LOW); //Establishes backward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 255); //Spins the motor on Channel A at FULL speed
  
  digitalWrite(10,LOW);  //Establishes backward direction of Channel B
  digitalWrite(2, LOW);   //Disengage the Brake for Channel B
  analogWrite(5, 255);    //Spins the motor on Channel B at FULL speed
 
 delay(1000);
 
   digitalWrite(9, HIGH);  //Engage the Brake for Channel A
  digitalWrite(2, HIGH);  //Engage the Brake for Channel B

  delay(500);

  digitalWrite(6,HIGH); //Establishes forward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 255); //Spins the motor on Channel A at FULL speed
  
  digitalWrite(10,HIGH);  //Establishes forward direction of Channel B
  digitalWrite(2, LOW);   //Disengage the Brake for Channel B
  analogWrite(5,0);    //Spins the motor on Channel B at ZERO speed
 
  Serial.println("if process ended - going to start loop again");
   delay(500);
  }
 


}

You need to start giving your pins names, and working out what your sketch is doing using serial prints.

Good job using code tags on your first post.

Although the code seems correct to me i can't make it work..

Please describe what the code does't do that you want it to do, and what the code does do that you do not want.

You have three different conditional sections of the code. Do any of the routines work correctly?

if  ( (digitalRead (Rswitch) == LOW) and (digitalRead (Lswitch) == LOW) ){

if ( (digitalRead(Lswitch) == HIGH ) ) {

if ( (digitalRead(Rswitch) == HIGH) ) {

Be aware that with all the delays() in your code, it will not be quickly responsive to any switch changes, but I'm not sure if that is your most immediate issue.

first of all thank you.As i previously described i just need it to go straight which actually means i need it to go forwards until one of the switches is activated.Once the switch is pressed once i'd like it to follow this sketch: stop-go back-turn-go forwards again until a switch is pressed..i managed to actually make it work at first but then what i believe happened is that it started reading the sketches all togehther..i'm starting to think that it is some kind of hardware disfunction

Your main problem is in using delays all over the place, delay just makes your program slow and un-responsive.

I suggest you study:
Using millis for timing
Demonstration for several things at the same time

Then, when you understand the examples, ditch your existing code and start again using what you have learnt.

Enjoy.

i'm starting to think that it is some kind of hardware disfunction

You need to verify that the digitalRead() of your switches put out HIGHS and LOWS as expected.
Your switch pins should be INPUT_PULLUP mode, and connect the input to ground when triggered. That way you will see the correct HIGH to LOW transition of your code logic. It's possible that your switches are "floating" if you don't have external pullups.

i managed to actually make it work at first but then what i believe happened is that it started reading the sketches all togehther.

What does this mean. Does each of the three motor move routines work by itself with no switches involved?