fixed [0]->[i]