refactoring linked list