Global variables can exist (and they will, in your driver script), but you must not access them directly from within your functions. You must pass those variables through the function's argument list, so that the information in the global variables is passed to local variables.