Updated foreach loop again after the revert of commit 1b24a6d40786f28c4c52b544ff33ecb08e197eaa