How about passing these values as local variables via parameters instead of using global variables?