slightly improved the way next/prev page was determined.