working version 1, output is untested.  Would like to seperate output by different windows.w