Setting selectedIndex to our calculated selected item