Simplify loop functions