implemented weighted loss