change loop structure