Yes, your function will work fine if you remove the global keywords.
global is used when you want to explicitly refer to a global variable from within a function. Consider this code:
foo = 1
function f()
println(foo)
end
function g()
foo = 2
println(foo)
end
function h()
global foo = 3
println(foo)
end
The following will happen:
f() # prints 1 because it prints the global `foo`
g() # prints 2 because it prints the local `foo`
h() # prints 3 because it sets the global `foo` to 3 and prints it
f() # prints 3 because it prints the global `foo` which has been set to 3 before