modified for OSX Mavericks