How to create a global variable from local scope (function)?