Modify pagination as per requirement.

Fixes #328