fixed bug in weight computation