Fixed an issue with loss calculation.