       filterDatasets();
                    });

                    searchHistoryList.appendChild(historyItem);
                });
            }

            // Toggle search history dropdown
            function toggleSearchHistory() {
                if (searchHistoryDropdown.style.display === 'block') {
                    searchHistoryDropdown.style.display = 'none';
                } else {
                    updateSearchHistoryUI();
                    searchHistoryDropdown.style.display = 'block'