fixed bug on remove duplicates