"soptimization" to use for-loops instead of foreach loops