Update iterative solution for better readability.