Can you figure this one out ?

OK i was on here the other day and asked for help with a problem " how to print voltage after reading it with an interrupt " well I was just trying out how to increment with an interrupt using same methods
as was explained to and I wrote this code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <avr/interrupt.h>
#include <util/delay.h>
LiquidCrystal_I2C lcd(0x3f, 20, 4);
int count = 0;
bool flag = 0;

void setup()
{
  lcd.init();                      // initialize the lcd
  lcd.init();
  lcd.backlight();
  lcd.print("COUNT=");
}
void loop()
{
  DDRB = 0b00000000;
  DDRD = 0b00000000;
  PORTD |= (1 << PORTB0);   // turn On the Pull-up PB0 is now an input with pull-up enabled
  PORTD |= (1 << PORTD3);   // turn On the Pull-up PD3 is now an input with pull-up enabled
  EICRA = (1 << ISC11) | (0 << ISC10); // set INT1 to trigger on falling edge
  EIMSK = (1 << INT1);     // Turns on INT1

  
  if (flag == 1) {
    lcd.setCursor(0, 0);
    lcd.print("COUNT=");
    lcd.print(count);
    flag = 0;
 

  }

  sei(); // turn on interrupts
}
//*************ISR************
ISR (INT1_vect)
{
  flag = 1;
  count++;
  _delay_ms(300);
}
//*****END-OF-ISR**************

the code works great but I have a denouncing problem it works good sometimes and sometimes it adds
2 or 3 times in one press i have tried using a delay in the code..does not help any thoughts on this ?

Do NOT put a delay inside an Interrupt Service Routine (ISR). An ISR must be fast, returning as quickly as possible. Delaying for 300 ms inside an ISR is a very bad thing to do.

The ISR could use a global variable to store the time that the button was last pushed. If the current time is less than 300 ms greater than the time stored in the global variable, the ISR should ignore the interrupt and just return, perhaps saving the current time in the global variable.

If the current time is is more than (or equal to) the time in the global variable, then save the current time in the global variable and perform whatever other processing that you want in the ISR.

Of course, most buttons are pressed by humans and do not need the speed of an ISR. The button could just be sampled in the loop() function.

ok i did this with out a delay at first ..the delay was an attempt to fix the problem but did not help

Look up "arduino button debouncing" There are libraries and tutorials.

You don't need a library to debounce a switch in an interrupt service routine. All you need to do is keep track of the time when the ISR is triggered. If this time minus last time is too small, ignore this interrupt. The blink without delay example has all the code you need.