somewhat strange that you are defining a method on the paginated_elements. If this method is used to get paginated results and the total count perhaps it could just have a double return:

return paginated_elements, elements.count

but i dont know the rest of the code well, so i might be totally off here