changed foreach loop variable so not modified