Fixing pagination bug