modified to compile and run on linux