refactoring doubly linked list