fixed global var nonsense