bug fix in weighted mean