updated to work on osx as well as linux