change timer from clock to gettimeofday