Added the weight calculation.