const latestKeyedText = cookies && cookies.searchHistory && cookies.searchHistory.length > 0 ? cookies.searchHistory[0] // Get the first item (latest) from the array : null;