changed linked lists to hash sets.