modfiy weighting function