replace iterator with indices for consistency