made some changes to structure of output. a global variable holds the running log