fixed bug with global variable assignment