fixed a problem in avg computation