remove duplicates script
updated index function