Fix weight calculation issue