Implementation of weight selection. DOES NOT COMPILE