Add page_count function