rearrange content for pagination