function with global and local variable