Made some changes to make it work on Mac