solution to deleteDuplicates
alternative solution to deleteDuplicates