moving loss functions into sag file