refactor pagination model. remove duplicated code and scopes