Combined loops for speed up