Minor fix in the weighting algo