Move panel_type_detect outside