I haven't looked up how index() works or how the iterations through sections.all() work (in terms of, does it consistently iterate in the same order / what order does it go through them in), so maybe this approach is perfectly fine. But my initial thought when seeing this is that it might be better to find the ClassSection via the DataTree, since that more than anything else is the definitive source of section numbers.