updated sort function and changed how page size is set