Fixed code to work on OSX