wrong index used  when selecting a search result. fencepost issue