Add utility function for pagination