fixed accidental clobber
fixed foreach bug