move offset to outer loop