Update weight and matching code