added loss function fix