How to clean address book?

I am trying to get rid of duplicate names in my address book, based on first names. This is the script I wrote. It runs, but does not seem to do anything. Anyone know why?

tell application "Address Book"
	set y to {}
	set x to name of every person in group "search"
	repeat with p in x
		if p is not in y then
			set end of y to p
		else
			delete person p
			save addressbook
		end if
	end repeat
end tell

Your script builds y as a list of references, rather than strings, bonedoc.

Instead of:

set end of y to p

… try:

set end of y to p's contents

(By the way, I take it you’re aware of AB’s Card/Look for Duplicate Entries. command?)