provided iterative solution