Servo Coding (need help)

hey, I need a little help in programing, I have two servo facing eachother, when I use the normal arduino code given in examples, I get both servo running perfectly but in opposite direction, instead I want both servos to run in same direction while facing each other so it would be like when one servo going from 0 to 45 degree the other should go from 45 to 0 degree, so here is the code I used.

#include <Servo.h> 
 
int relay2 = 2;
Servo servo8;

int relay3 = 3;
Servo servo9;

int pos = 0;    // variable to store the servo position 
 
void setup() 
{ 
    pinMode(relay2, OUTPUT);
  servo8.attach(8);
  
  pinMode(relay3, OUTPUT);
  servo9.attach(9);
  
} 
 
 
void loop() 
{ 
  
  digitalWrite(relay2, HIGH);
  digitalWrite(relay3, HIGH);
  delay(500);
  for(pos = 0; pos < 45; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    servo8.write(pos);              // tell servo to go to position in variable 'pos' 
    servo9.write(pos);
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
  for(pos = 45; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    servo8.write(pos);              // tell servo to go to position in variable 'pos' 
    servo9.write(pos);
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
  digitalWrite(relay2, LOW);
  digitalWrite(relay3, LOW);
  delay(500);
}

currently these both servo are set in same motion as you can see in the code, but I want them to go opposite simulateously at the same time just like I said before. I tried different techniques, but nothing seems to be work because I am at very basic level and one more important thing that I am using this code because I want to control the timing.

thanks

Well you don't say what you tried, but how about this as an idea:

Instead of:

    servo8.write(pos);             
    servo9.write(pos);

Try this:

   servo8.write(pos);             
    servo9.write(180-pos);

Awesome, it worked, thank you very much mate.