modifiy to work on both Mac OS X and Linux