fixed cross platform issue and the fact the program never exits