rework approach again to used doubly linked list and be cleaner