try to optimise but failed
optimise the timing and save nearly half time; calculate the average value