Undefined index weight fixed

if index is undefined just set to default 0