Fixing index issues of addNode()