added code working on macOSX 10.8.4