added code to reverse singly linked list