change compare to vec and fit i to a[i]