Function to return currently selected index