compiles and works on linux. for windows, see commit #2