IR object counter(total count,# of vacant, occupied)

Hi, I'm creating a project for my pre-oral defense in a thesis. What I'm trying to do is using an IR sensor, I'm going to count the total number of the vehicle that parked in the parking lot also the number of vacant and occupied space. for my prototype, I'm using 2 sensors but in my code shown below is only one.

int pin=4;
int Occupied=0;
int detected=false;
int Vacant=0;

void setup() {
  Serial.begin(9600);
  pinMode(pin,INPUT);
}


void loop(){
  count();
}
void count() {

    int val=digitalRead(pin);
  if( (val == 0) && (detected == false )  ){
          Occupied++;
          detected = true;
          delay(2000);
         
          Serial.print("occupied =");
          Serial.println(Occupied);
      }
       if( (val == 1) && (detected == true ) ){

          Vacant-Occupied;
          detected =false;
          Serial.print("Vacant =");
          Serial.println(Vacant);
          
          
  
}

}

my problem is first, the total number of vacant is not detected, second, when I put my hands in the sensor(to det. detection) it adds one but when i pull out my hands out the sensor it's still count number of detected not the vacant one that's the problem. and lastly, i don't know how to put the other sensor and do what the existing sensor does.

anyone can help me about this? I appreciate alot

Try here