fixed indexes computation bug