refactor pagination service