added code to reverse single linked list