fixed deleteDuplicates function