tidy code
if the index is 0 - just close the node