Refactor ui pagination