calculate avg value function is done.