created a fn 'get_selected_entities' to avoid duplication