updated removeDuplicates and tests