added dynamic weighting