fixed averaging issue