loop creation improvment