wrote some of the code for the EliminateDuplicates method