I got a bizarre case inside my function.
So, I have a variable that is equal to 2000 by default. There are no places where I set the value.
And here are two variants of the function. For the short intro, I set a new value at the end
Your variable is not a function variable. Its a global variable so when it runs first time it will store the value (1794 or something) but when you run the function again last value is there.
In the second case you initialize the variable at the beginning of the function so it will be always 2000 and then you put a different value there so the logic that is running here is right