implementing a method to remove duplicates from a linked list