Fixed weight assigning function.