VERSE - player Reference device - know in which device the player is registered

well, sadly I encounter a probably similar issue after editing the code to add some logic variables.
The goal is to check for each register device if it is empty ( no player registered in it)
and then register the player that have triggered the trigger in one of the 2 devices when the is a free slot basically .
I’m not sure if It is the appropriated manner to achieve that though, so feel free to challenge the approach.
I was hopefull there is an built in solution for checking wether or not a register device is empty but I just found this way to check if a player is registered with “isregistered”.

I would be grateful if someone can help me fixing it

below the script which have some errors :

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# Class to handle checking registered players when a trigger is activated
player_registration_checker := class(creative_device):

    # Editable references to the player reference devices
    @editable
    PlayerReferenceDevice : player_reference_device = player_reference_device{}

    @editable
    PlayerReferenceDevice2 : player_reference_device = player_reference_device{}

    # Trigger device to detect player interactions
    @editable
    TriggerDevice : trigger_device = trigger_device{}

    # OnBegin is called when the device is initialized
    OnBegin<override>() : void =
        # Subscribe to the trigger event
        TriggerDevice.TriggeredEvent.Subscribe(OnTriggerDetected)
        Print("Waiting for a player to trigger the device...")

    # Event function called when the trigger is activated by a player
    OnTriggerDetected(TriggeringPlayer: ?agent): void =
        Print("Trigger activated by player, checking registration...")
        # Check if TriggeringPlayer exists before proceeding
        if (TriggeringPlayer?):
            CheckRegisteredPlayers(TriggeringPlayer)
   

    # Function to get the current list of players and check registration
    CheckRegisteredPlayers(TheTriggeringPlayer: ?agent)<transacts><decides> : void =
        # Get the current list of players in the game
        currentPlayers : []agent = GetPlayspace().GetPlayers()
        
        foundOnePlayer := false
        foundOnePlayer2 := false

        # Check each reference device to see if a player is registered
        for (theCurrentPlayer : currentPlayers):
            if (PlayerReferenceDevice.IsReferenced[theCurrentPlayer]):
                foundOnePlayer = true

        for (theCurrentPlayer : currentPlayers):
            if (PlayerReferenceDevice2.IsReferenced[theCurrentPlayer]):
                foundOnePlayer2 = true

        # Register the player if a device does not contain any player  registered
        if (not foundOnePlayer?):
            PlayerReferenceDevice.Register(TheTriggeringPlayer)
        else if (not foundOnePlayer2?):
            PlayerReferenceDevice2.Register(TheTriggeringPlayer)