Bunch of refactoring. fix search criteria next page issue