create weighting function and update comments