modified to support OSX as well