Fix next page logic