Didn't try, but I would think you can move the iternext definition outside, since the function should just work with whatever dataptrs it sees.