I want to know what's wrong with my coding

well, i want like below:

unsigned long currentTime = 0;
unsigned long previousTime1 = 0;
unsigned long previousTime2 = 0;

void setup()
{
pinMode(12, INPUT); // pressure switch low input
pinMode(2, OUTPUT); // compressor-01 start command
}

void loop() {
unsigned long currentTime = millis();
if (digitalRead(12) == HIGH && currentTime-previousTime1>=2000) // when pressure switch is low which detected by arduino as high input & 2 sec delay
{
digitalWrite(2, HIGH); // compressor-01 start command
previousTime1 = currentTime;
if (digitalRead(12) == HIGH && currentTime-previousTime2>=6000) // compressor-01 remain running for from 2 sec to 6 sec
{
digitalWrite(2, LOW); // after 6 sec compressor-01 stop command
previousTime2 = currentTime;
}

else {
digitalWrite(2, LOW); // if pressure switch is high which detected by arduino as low input for compressor-01 stop command.
}

}
}