fixed two issues with weights: length and isnan