Fix pagination counting previous pages in reverse on the last page