Button debounce code + IR relay code problem

Previously I had made a IR relay circuit in which i want to add a push button in order to control one of the relays i.e. Relay 1 must be controllable from button as well as ir remote control. There comes a button bouncing problem so i have added a debouncing code in the normal ir code, as follows:-

#include <IRremote.h>




const int RECV_PIN = 11;
const int r3 = 9;
const int r2 = 12;
const int r1 = 10;
const int buttonPin = 2;    // the number of the pushbutton pin
   
// Variables will change:
int r3State = HIGH;         // the current state of the output pin
int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin




// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers




    
IRrecv irrecv(RECV_PIN);




decode_results results;




void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(r3,OUTPUT);//Pin For relay3
  pinMode(r2,OUTPUT);//Pin For relay2
  pinMode(r1,OUTPUT);//Pin For relay1
  pinMode(buttonPin, INPUT);
  digitalWrite(r3, r3State);
}




void loop() 
{
  int reading = digitalRead(buttonPin);




  // check to see if you just pressed the button
  // (i.e. the input went from LOW to HIGH),  and you've waited
  // long enough since the last press to ignore any noise:




  // If the switch changed, due to noise or pressing:
  if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }




  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:




    // if the button state has changed:
    if (reading != buttonState) {
      buttonState = reading;




      // only toggle the LED if the new button state is HIGH
      if (buttonState == HIGH) {
        r3State = !r3State;
      }
    }
  }




  // set the LED:
  digitalWrite(r3, r3State);




  // save the reading.  Next time through the loop,
  // it'll be the lastButtonState:
  lastButtonState = reading;





 if (irrecv.decode(&results))                
  {
    
    if(results.value==1930688319)//<--Relay1
  {
      if(digitalRead(r3)==LOW)
      {
        digitalWrite(r3,HIGH);
       
        
      }
      else{
    digitalWrite(r3,LOW);
    
    }
  }
    if(results.value==1440415647)//<--Relay2
    {
      if(digitalRead(r2)==LOW)
      {
        digitalWrite(r2,HIGH);
       
      }
      else{
    digitalWrite(r2,LOW);
 
    }
    }
    if(results.value==130972539)//<--Relay3
    {
      if(digitalRead(r1)==LOW)
      {
        digitalWrite(r1,HIGH);
     
      }
      else{
    digitalWrite(r1,LOW);
 
    }
    }
    if(results.value==3173222979)//<--power button
    {
       if(digitalRead(r1)==HIGH)
      {
        digitalWrite(r1,LOW);
        
      }
       if(digitalRead(r2)==HIGH)
      {
        digitalWrite(r2,LOW);
       
      }
     
     if(digitalRead(r3)==HIGH)
      {
        digitalWrite(r3,LOW);
        
      }
    }
     irrecv.resume();
  }                              
        
}

But with this code the relay 1 (only) no more can be controlled with ir remote, although it can be controlled by pushbutton without any bounce interruptions. I need it to be controlled by both. I know there is some problem with code only thats why i put this post in this section of forum. Kindly help me out.

Try changing:

r3State = !r3State;

to:

r3State = buttonState;

Yeah, i have already the same code in 'if statement' above, check out.