Use Iterator.enumerate() to reduce boundary checks