Outer loop calculation part