fix invalid argument for foreach