Use while loop instead of recursion.