Umwandlung foreach loop -> for loop