added reordering in weighted average