Improve readability of weighting function