Fixed selected index bug