first code to detect selected items