adding helper function for pagination