adapted to MacOS