Make for loops compatible with older C++ versions