Why is next skipping to the 'wrong' page?