[bug973119] - wrapped code in 'function' in order to get rid of global variables