Implemented reversing a linked list