coded up reweighting