hey, i have a program to create bulk time off data and it works so far except one part. the code im going to share is to create a pop up window to project data gathered from main window also allows user to make selection from the list. in this pop up window i am trying to implement a button and a search bar. when button is pressed it should get the user input from the searchbar and the selected rows from the list so it can replace the first employee name with the new one and also replace id with a new random generated one then add these rows to the existing list. so far it works but when it adds new rows to the one already exist, it resets the selection made by the user which i need to avoid. can you help me? here is the code: def show_confirmation_window(data, root, existing_top=None, existing_table=None, existing_check_vars=None):
    # Function to add another employee
    def add_another_employee():
        # Reset the live search bar
        new_employee = entry.get()
        if not new_employee:
            messagebox.showerror("Error", "Please select an employee!")
            return

        # Get the checked data from the current table
        checked_data = [row for i, row in enumerate(data) if check_vars[i].get()]

        # Copy the selections and add new employee data
        new_data = []
        for row in checked_data:
            random_id = generate_random_id()
            new_data.append([random_id, new_employee, row[2], row[3], row[4]])

        # Update the existing confirmation window with new data
        show_confirmation_window(new_data, root, top, table, check_vars)
    # Check if we are updating an existing window
    if existing_top and existing_table and existing_check_vars:
        top = existing_top
        table = existing_table
        check_vars = existing_check_vars
    else:
        # Get master window position
        root_x = root.winfo_rootx()
        root_y = root.winfo_rooty()
        # Add offset
        win_x = root_x + 568
        win_y = root_y - 31

        # Toplevel Window to Display Time off Data List
        top = ctk.CTkToplevel(root)
        top.wm_iconbitmap()
        top.after(300, lambda: top.iconphoto(False, root.iconpath))
        top.geometry("950x500" + f'+{win_x}+{win_y}')
        top.title("Confirm Time-Off Entries")

        # Frame to Contain Treeview Widget
        frame = ctk.CTkFrame(top)
        frame.pack(fill="both", expand=True, padx=20, pady=15)

        # Style for Column Headings
        style = ttk.Style(top)
        style.theme_use("alt")
        style.configure("Treeview.Heading", background=p_green, foreground=p_cream, font=("Bahnschrift", 12), hover=False)

        # Table to display rows (without ID in columns but still accessible in the data)
        table = CheckboxTreeview(frame, columns=("Name", "Type", "Start", "End"))

        # Set the headings without showing the "ID"
        table.heading("Name", text="Employer Name")
        table.heading("Type", text="Type of Time Off")
        table.heading("Start", text="Start Date & Time")
        table.heading("End", text="End Date & Time")

        check_vars = []
    
        # Entry Box Widget Combined with Scrollable Dropdown Widget
        entry = ctk.CTkEntry(top, textvariable=entry_name, width=240, fg_color=p_cream, text_color=p_green_d, font=("Bahnschrift", 15))
        entry.pack()
    
        CTkScrollableDropdown(entry, values=name_list, command=lambda e: (entry.delete(0, 'end'), entry.insert(0, e)),  # Clear and insert
                              fg_color=p_cream, text_color=p_cream, hover_color=p_green, autocomplete=True, font=("Bahnschrift", 12, "bold"))
    
        # Add Another Employee button
        add_employee_button = ctk.CTkButton(top, text="Add Another Employee", command=add_another_employee, fg_color=p_blue,
                                            hover_color=p_red, text_color=p_cream)
        add_employee_button.configure(font=("Bahnschrift", 15, "bold"))
        add_employee_button.pack(pady=15)
    
        # Confirmation button
        confirm_button = ctk.CTkButton(top, text="Confirm & Save", command=lambda: [save_confirmed_rows(data, check_vars), top.destroy()], fg_color=p_blue,
                                       hover_color=p_red, text_color=p_cream)
        confirm_button.configure(font=("Bahnschrift", 15, "bold"))
        confirm_button.pack(pady=15)

    # Add data to the table without displaying the "ID" column
    for i, row in enumerate(data):
        # initial_state = row[5] if len(row) > 5 else True  # Default to True if no state is provided
        # check_var = tk.BooleanVar(value=initial_state)
        check_var = tk.BooleanVar(value=True)
        check_vars.append(check_var)
        table.insert("", "end", values=(row[1], row[2], row[3], row[4]), tags=(f"row{len(check_vars) - 1}",))
        table.tag_bind(f"row{len(check_vars) - 1}", "<<TreeviewSelect>>", lambda e, var=check_var: var.set(not var.get()))
        table.check_all()
        if ((len(check_vars) - 1) % 2) == 0:
            table.tag_configure(f"row{len(check_vars) - 1}", background=p_yellow_l)
        else:
            table.tag_configure(f"row{len(check_vars) - 1}", background=p_yellow_d)

    table.column("# 0", width=50)
    table.pack(expand=True, fill='both', padx=10, pady=10)

# This function saves only the confirmed rows
def save_confirmed_rows(data, check_vars):
    # Filter rows based on checked boxes
    confirmed_rows = [row for i, row in enumerate(data) if check_vars[i].get()]
    create_excel(confirmed_rows)