Fix pagination logic
Issue #73
Still needs improvements (this does not show the total number of pages)