minor revision, add sanity check and api to get weights by name