fixed pagination bug that would not take into account ordering