implement weighting function(fill out with the formula)