fix paginate function
Revert "fix paginate function"

This reverts commit 9daf54f05427ca0faa33e22e6a4422e178b00949.
Revert "Revert "fix paginate function""

This reverts commit 2bff7099479f00a370ec6434344a8f1ea09c2d6b.