changed function for g++ compile and run.