iterative solution