calculate and emit avgerage