Put in iterative approach (to the recursive problem)