better pagination and bug fix