modified, but doesnt work on MacOS X