Thanks hopfel, they need to be placed before starting the loop.
This did not change the behavior of the script. I guess it reduces the space reserved for the game.