handle edges cases in weighting