fix select_page logic