some changes in calculating average