fix average bug