         document.getElementById('teamMembers').value = "";
            document.getElementById('selectedMembers').value = Array.from(selectedUsersContainer.children)
                .map(child => child.dataset.username)
                .join(',');
            document.getElementById('userDropdown').innerHTML = "";
        }

        // Remove user from selected list
        function removeUser(element) {
            const userDiv = element.parentElement;
            userDiv.remove();
        }

        // 