add a new paging util file
refactor code and add paging logic