fix bug with globalizing of variables