foreach bug