NDM fixed

solved problem in damage to loss function