fix weight average calculation