remove duplicates from sorted array - fix a bug