JavaScript now handles pagination from the first to the last page, however bug present where it paginates to a 404 page after the last page