Motor - Count time - Change direction

I'm back.
I have arrange what Steve pointed me yesterday and I arranged another things. It works bad but ..
When it starts the sensor calibrates and then the sensor detects the movement.
But without ant button pressed once movement is detected the motor starts following the directions of the button in Pin 9, if I push the 8 it changes direction but only if I am pushing when I leave it the motor returns to the other direction. I would need that the momentary pressure fix the direction until the next change.
When the movement stops the motor stops. But the PIR is not waiting for the transition (PAUSE TIME) to LOW.
Here the modified code

//VARS
//the time we give the sensor to calibrate (10-60 secs according to the datasheet)
int calibrationTime = 30;        

//the time when the sensor outputs a low impulse
long unsigned int lowIn;
//the amount of milliseconds the sensor has to be low
//before we assume all motion has stopped
long unsigned int pause = 10000;
boolean lockLow = true;
boolean takeLowTime;
const int pirPin = 2;    //the digital pin connected to the PIR sensor's output
const int button1Pin = 8;     // the number of the pushbutton1 pin
const int button2Pin = 9;     // the number of the pushbutton2 pin
const int IN3 = 5; 
const int IN4 = 4;
const int ENB = 3;   
int button1State = 0;         // variable for reading the pushbutton status
int button2State = 0;         // variable for reading the pushbutton

void setup() { 

  //start serial connection
  Serial.begin(9600);
    // initialize the pushbutton pin as an input:
  pinMode(button1Pin, INPUT);     
  pinMode(button2Pin, INPUT);   
digitalWrite(button1Pin, LOW);
digitalWrite(button2Pin, LOW);
  // initialize the H-Bridge pin as an output:
 pinMode (ENB, OUTPUT); 
  pinMode (IN4, OUTPUT);   
  pinMode (IN3, OUTPUT);
  
  digitalWrite(IN3, LOW); 
  digitalWrite(IN4, LOW); 
   pinMode(pirPin, INPUT);
 
 digitalWrite(pirPin, LOW);

  //give the sensor some time to calibrate
  Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++){
      Serial.print(".");
      delay(1000);
      }
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");
    delay(50);
  }

void loop() {
 
// read the state of the pushbutton values:
  button1State = digitalRead(button1Pin);
  button2State = digitalRead(button2Pin);
  digitalRead(pirPin);

  if (digitalRead(pirPin) == HIGH && millis() > 1000) {
  if (button1State == HIGH){
        // Motor one direction
  analogWrite(ENB,220);
  digitalWrite (IN4, HIGH);
  digitalWrite (IN3, LOW); 
   } 
   else if (digitalRead(pirPin) == HIGH && millis() > 1000) {
    if (button2State == HIGH);
  
    // Motor other direction
  analogWrite(ENB,220);
  digitalWrite (IN4, LOW);
  digitalWrite (IN3, HIGH);
    } 
    if (lockLow) {
      //makes sure we wait for a transition to LOW before any further output is made:
      lockLow = false;
      Serial.println("---");
      Serial.print("motion detected at ");
      Serial.print(millis() / 1000);
      Serial.println(" sec");
      delay(50);
  }  
    takeLowTime = true;
 }
   else if (digitalRead(pirPin) == LOW) {
    if (takeLowTime) {
      lowIn = millis();          //save the time of the transition from high to LOW
      takeLowTime = false;       //make sure this is only done at the start of a LOW phase
    }
    //if the sensor is low for more than the given pause,
    //we assume that no more motion is going to happen
    if (!lockLow && millis() - lowIn > pause) {
      //makes sure this block of code is only executed again after
      //a new motion sequence has been detected
      lockLow = true;
      Serial.print("motion ended at ");      //output
      Serial.print((millis() - pause) / 1000);
      Serial.println(" sec");
      delay(50);
      analogWrite(ENB,0);
  
    }

      delay(50);
      analogWrite(ENB,0);
 
     }
    }

Thank you

rudni