add selectedindex to function