add support for osx, avoid setting global variables