FIXED: correct nodes_size. nodes_size is the number of nodes + 1, so for loops need the < instead of <=