Simplify iteration code