Fixing pagination bug when passed -1 as page in query