fix bugs when creating a linked list or a tree