added remove duplicates inplace