Refactoring way to pagination search.