remove duplicate without permanently changing array