handle nil selected_key