Refactor to doubly linked list