Implementing pagination and sort by in the pages