added tryparse to default an invalid weight to zero