simplify iterator code