fixed find_max_weight_algo