changed stack to global var