changed to foreach