Refactors linked list