fixed scope issues, no more global