Fixed averaging issue