Changed page_number algorithm