Fixed bug in weight calculations