Arduino automated Rpm system

Hey guys , i am making an automated rpm system that should keep the Rpm in a given interval.I have broken the problem into making an interval via 4 buttons, incrementing and decrementing two values.
Reading the Rpm of a motor shaft using a Hall sensor .
Controlling the servo by veryfing if the rpm read from the Hall sensor is within the values of the interval.
My problem is that i cannot seem to get it to function in the one schetch .
It works fine if i run individual parts but when put together i can only increment,decrement the interval values, the servo does not respond. I can make it respond if i initialize the values buttonPushCounter1 and buttonPushCounter1 from the begining .
Please ignore the comments,most of them are in Romanian.

      #include <Servo.h>
      Servo myservo;
      int pos = 0 ;
      int rot = 0 ;
      const int buttonPinA = 2;     // + for MinRpm
      const int buttonPinB = 4;     // - for MinR[m
      const int buttonPinC = 7;     //  + for MaxRpm
      const int buttonPinD = 8;     // - for  MaxRpm
      
       
      
      int buttonPushCounter1 ;  // counter for the number of button presses for the Minimum rpm that i will be using to display on the lcd and also for setting the movement interval for the servomotor
   
   int buttonPushCounter2 ;   // counter for the number of button presses for the Maximum rpm that i will be using to display on the lcd and also for setting the movement interval for the servomotor
      int buttonStateA = 0; 
      int buttonStateB=0;           // current state of the button
      int buttonStateC = 0;
      int buttonStateD = 0;
      int lastButtonState = 0;     
       
      
      void setup() {
        // put your setup code here, to run once:
        myservo.attach(9);   
   
        pinMode(buttonPinA, INPUT);
        pinMode(buttonPinB, INPUT);
        pinMode(buttonPinC, INPUT);
        pinMode(buttonPinD, INPUT);
        // initialize serial communication:
        Serial.begin(9600);
      }
      void holdPosition() {
        myservo.detach();
      }
      void servoCresteRotatiile() {
        rot = rot + 1;
        pos += 3;
        myservo.write(pos);                   
 delay(50      }  
      void servoScadeRotatiile() {
        rot = rot - 1;
        pos -= 3;
        myservo.write(pos);
      }
      
      void loop() {
         pos = constrain(pos, 0, 180);              // pos se va gasii intre 0 si 180 grade
        buttonStateA = digitalRead(buttonPinA);
      buttonStateB = digitalRead(buttonPinB);   
                if (buttonStateA != lastButtonState) {
          if (buttonStateA == HIGH) {
            buttonPushCounter1++;
            Serial.print("  creste Min Rpm: ");
            Serial.println(buttonPushCounter1);
          }
          delay(50);       
        }
        buttonStateA = lastButtonState;
      
       
       buttonStateB = digitalRead(buttonPinB);
         if (buttonStateB != lastButtonState) {
           
           if (buttonStateB == HIGH)
           { 
            buttonPushCounter1-=1;               Serial.print(" scade Min Rpm:  ");   
            Serial.println(buttonPushCounter1);
           }
               delay(50); 
         } 
          lastButtonState = buttonStateB; 
      
       buttonStateC = digitalRead(buttonPinC);
          int lastButtonStateMax = 0;
        if (buttonStateC != lastButtonStateMax) {
          if (buttonStateC == HIGH) {
                        buttonPushCounter2++;
            Serial.print("  creste Max Rpm:  ");
            Serial.println(buttonPushCounter2);      // Serial.println(buttonPushCounter2)  sau  Serial.println(buttonPushCounter1);
          }
          delay(50);
        }
        buttonStateC = lastButtonStateMax;
       buttonStateD = digitalRead(buttonPinD);
         if (buttonStateD != lastButtonStateMax) {    
           if (buttonStateD == HIGH)
           {     
            buttonPushCounter2-=1;   // la fel cu buttonPushCounter2=buttonPushCounter2-1;     
            Serial.print(" scade Max Rpm:  ");   
            Serial.println(buttonPushCounter2);//  Serial.println(buttonPushCounter1) sau  Serial.println(buttonPushCounter2);     
           }    
               delay(50); 
         } 
          lastButtonStateMax = buttonStateD;                                                                         
               if ( (rot > buttonPushCounter1) && (rot < buttonPushCounter2) )       
        {
          holdPosition();                          // myservo.detach();
        }
        else if  (rot <= buttonPushCounter1)
        {
          servoCresteRotatiile();                 
      
        } else if (rot >= buttonPushCounter2;
        {
          servoScadeRotatiile();                  
        }                                      
        delay (300) ;
      }

Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum Your code is too long to study quickly.

Also please use the Auto Format tool to lay it out so it is easy to follow.

If you want something to be responsive you should not use delay(). Have a look at how millis() is used to manage timing in several things at a time

…R