refactored pagination ordering

refactored pagination ordering