this is used to reverse the doubly linked list