fix loss accounting bug