the iterative definition is faster
resolved merge conflict, with iter branch