Changed prototype of weight_func