OH3 from 2.5 Rule no longer seems to work?

So I have added a ton of logging and my rule now looks like this:

import org.openhab.core.model.script.ScriptServiceUtil

var registry = ScriptServiceUtil.getItemRegistry()

rule "Pin Input"
when
    Item Pin_Number_Input received update
then
    logWarn("Pin_Number", "Rule is running and registry variable is: {}",  registry)
    var update = Pin_Number_Input.state.toString()
        logWarn("Pin_Number", "Entered Pin Number update Variable is: {}",  update)
        logWarn("Pin_Number", "Entered Pin Number State is: "+  Pin_Number_Input.state.toString)

    if (update == "") return;

    logWarn("Pin_Number", "{}: {}", Pin_Number_Input.name, update)

    var target = registry.get(Pin_Number_Input.label)
    logWarn("Pin_Number", "target variable is: {}",  target)

    if (target !== null) {
        var text = target.state.toString()
        logWarn("Pin_Number", "text variable is: {}",  text)

        if (text == "" || text == "NULL") {text = "_"
        logWarn("Pin_Number", "text should be _ variable is: {}",  text)}
        else if (!text.contains("_")) {text += "_"
        logWarn("Pin_Number", "text 2 variable is: {}",  text)}

        if (update.length() == 1) {
                text = text.replaceFirst("_", update + "_")
         }
        else if (update == "DELETE") {
                text = text.replaceFirst("._", "_")
        }
        else if (update == "DONE") {
                text = text.replaceFirst("_", "")
                        createTimer(now.plusSeconds(10), [
                        Pin_Number.postUpdate("_")
//                      Pin_Number_Input.postUpdate("")
                        ])
        }

        //text = text.substring(0, 1).toUpperCase() + text.substring(1).toLowerCase().replace("  ", " ").split(" ").reduce([capitalized, word | capitalized + " " + word.substring(0, 1).toUpperCase() + word.substring(1)])

        if (text.contains("_")) target.postUpdate(text)
        else target.sendCommand(text.trim())
                    logWarn("Pin_Number", "EnteredPin " + Pin_Number.state  )
    }
//        createTimer(now.plusSeconds(10), [
//                            Pin_Number.postUpdate("")
//                            Pin_Number_Input.postUpdate("")
//        ])
 
end

And I get the following logs when I input the first number (1 in this case):

07:56:40.715 [WARN ] [.openhab.core.model.script.Pin_Number] - Rule is running and registry variable is: org.openhab.core.internal.items.ItemRegistryImpl@10ca435b
07:56:40.715 [WARN ] [.openhab.core.model.script.Pin_Number] - Entered Pin Number update Variable is: 1
07:56:40.730 [WARN ] [.openhab.core.model.script.Pin_Number] - Entered Pin Number State is: 1
07:56:40.730 [WARN ] [.openhab.core.model.script.Pin_Number] - Pin_Number_Input: 1
07:56:40.730 [WARN ] [.openhab.core.model.script.Pin_Number] - target variable is: {}

So looks like my issue is:

    var target = registry.get(Pin_Number_Input.label)
    logWarn("Pin_Number", "target variable is: {}",  target)

    if (target !== null) {

It seems target is null ? As rule seems to exit at this point?

Any ideas? This used to work on 2.5?
EDIT:

Found this article:

Which seems to indicate that I should be using:

val target = ScriptServiceUtil.getItemRegistry.getItem("Pin_Number_Input") //as GenericItem

Which gives me:

09:32:04.873 [WARN ] [.openhab.core.model.script.Pin_Number] - testItem variable is: Pin_Number_Input (Type=StringItem, State=1, Label=Pin Number Input, Category=, Groups=[Pin_Input])

However that causes the rules to get stuck in a loop.

Cheers
Mark