code for post-processing weights