linked list refactored