Your Z loop increments Z by 6 for each iteration.
You increment Z by 5 manually within the loop, and the NEXT Z used to close the loop iterates another 1.

If you take the difference between your start and end indexes for each digit A and B,
the difference between A and B for digit zero is the only set that is evenly divisible by 6.
The other digits overshoot the loop index by 2.