optimizing left/right loop