reordered loop