By the way, please format your code nicely. Just surround your code with triple backquotes. Code Formatting
Why are you modifying the port identifier in your makePort
function?
Port identifiers need to be unique within a Node, but different Nodes can use the same portIds. That was the case with the original code, where the template assigned a different letter to each port element.