Adjusted searchHistory functionality to select the most likely entry