fixed the pagination bug