attiny85 + esp8266 + button = :(

Hi, i'm trying to get work an attiny85 with an esp8266 wifi module, to control a led. I can do it, but i need to integrate a button to do the same that the esp8266, but manually. I have this code:

void loop() 
{
  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH && lastButtonState == LOW) {
    delay(50);
    if (ledState == 0) {    
      digitalWrite(led, HIGH);
      ledState = 1;
    }
    else {
      digitalWrite(led, LOW);
      ledState = 0;
    }
  }
  lastButtonState = buttonState;
  
  if (finder.find("led1off")  ){
    digitalWrite(led, LOW);
    ledState = 0;
  }
  if (finder.find("led1on")  ){
    digitalWrite(led, HIGH);
    ledState = 1;
  }
}

the finder part, works perfect, but the button doesn't. If i put only the button code, it works, but it doesn't work if i put it together. Sometimes turn on/off and sometime makes esp8266 reset. Please help.