That would be a typo with the z, my bad. As for the allocation at the end of the loop, I did that because you were always allocating the "head" node but not using it. Now it uses the head node, nothing more :-)