replace useless next_index function with variable.