try setting prevWeights at the end of the loop