Pagination group by nightmare