Replacing function parameters by global variables