Fix Pagination logic