adding support for different loss functions