create correct loop