fixed i, i-1 error