Refactored getSelectedItem and added filter on change