Debugged global var problem