refactored loss_curve_almost_equal