script in foreach loop