fix bug that created/used global variable