Is there a way you could do this without a while loop?
we try not to have while loops in the core.