iterative approach