simplify loops