using interrupts

byte PWM_PIN = 2;
 int pwm_value;
 const int ledpin=13; 
void setup() {
  // put your setup code here, to run once:
 pinMode(PWM_PIN, INPUT);
 pinMode(ledpin, OUTPUT);
 Serial.begin(115200);
 

}

void loop() {
  // put your main code here, to run repeatedly:
pwm_value = pulseIn(PWM_PIN, HIGH);
Serial.println(pwm_value);

if(pwm_value == 2)
{
  digitalWrite(ledpin, HIGH);
  delay(1000);
  digitalWrite(ledpin, LOW);
  delay(1000);
  return 0;
}
else if(pwm_value==5)
{
  
 digitalWrite(12, HIGH);
 delay(1000);
 digitalWrite(12, LOW);
 delay(1000);
 return 0;
}
}

how about this code

please help me get out of the if loop and please check if this code checks all the pulses and then executes