changes loop ordering