fixed bug in weights, it's matrix not jmatrix