Added proper averaging