pagination query error fixing