Ups, you're right. I will correct it today, but I don't think that this is the main problem, because I don't use the buttons to change the speed and the motor just stops.
However, that gave me smth to think about. Maybe somehow now the pin connected to the "decrease" button is by default low, so in each loop program reduces the speed by one step, even though I didn't press anything?
Maybe I should somehow configure the pins connected to buttons to detect button press correctly?