linked list memory leak resolved