Changed to foreach loop