factor out moving over loci to an iterator to allow for folds