Minor changes pagination logic