pagination and bug fix