doing reversed linked list function