fix bug with selectedIndex