Fix a bug on pagination