Modernize a couple of loops