Fix pagination condition. It's still a hack and will be removed shortly.