Added removeDuplicates function.