fixed the bugs in the featureWeights function