didn't understand why global var doesn't work. trying this though.