compiles correctly with globals now