replace recursion with iteration