The recursive call was replaced with a while loop.