refactor pagination component