fix memory leak
free the linked list