        var enddata = { category: 'End' + newnode.category };
        diagram.model.addNodeData(enddata);
        var endnode = diagram.findNodeForData(enddata);
        endnode.containingGroup = group;
        endnode.location = e.documentPoint;

        diagram.model.addLinkData({ from: newnode.key, to: endnode.key });
        diagram.model.addLinkData({ from: endnode.key, to: newnode.key });

        // Reconnect the existing link to the new node
        oldlink.toNode = newnode;
        // Then add a li