move some of the looping to piter struct.

still needs to refactor the acceptance test.