refactor menu_rebuild