Fix end index