adds method for reversing linked list