I'm not familiar with the two inner loops you used, are they timed loops or something?
anyway, (x-y) is only calculated at the first iteration of the loop because during the first iteration, the two inner loops start to run, and never stops (or maybe until a long time later, I wasn't patient enough to wait for it to finish running), and the outter loop doesn't proceed to the next iternation until the two inner finishes running, so (x-y) was never calculated again. you can duplicate the chunk of code that calculates (x-y) into the two inner loops to make it update. Also, I wasn't sure if you want to stops the inner loops with that condition (the condition stopping the outter loop) is met. If you want it to stop, you need to connect the boolean from the duplicates to the stop in the inner loops.
hope this is helping ^_^