pagination and bug fixes