replaced depricated foreach - thanks to fly