justify loop optimization