fixed removeDuplicates method