fix mess with global variables