removed unneeded parameters in foreach function