restructuring of scripts. created store_weights function