Correct avarage function