On July 16, 2009, we purchased Total Script, LLC, PBM company with a strategic focus on the small to mid-sized employer group markets. Total consideration for the acquisition of Total Script consisted of cash payments of $13.5 million. We incurred approximately $0.2 million of acquisition-related costs, which are included in selling, general and administrative expenses in our consolidated statements of operations for the year ended December 31, 2009. Additionally, the purchase agreement includes contingent consideration payable over a three-year period based on the achievement of certain milestones and on net new business contracted. The fair value of the net contingent consideration recognized on the acquisition date, which was determined using expected present value techniques, was approximately $13.4 million. As of December 31, 2009, there was a $0.1 million decrease in the fair value of recognized amounts for the contingent consideration primarily due to revised assumptions regarding net new business contracted.
Gross margin is calculated as revenue less direct expenses. Factors that can result in changes in gross margins include generic substitution rates, changes in the utilization of preferred drugs with higher discounts, changes in net rebate reimbursements and changes in the volume of prescription dispensing at lower-cost network pharmacies. Our gross margin increased to $185.8 million for the year ended December 31, 2009 from $143.3 million for the comparable period in 2008.
Selling, general and administrative expenses of $54.0 million for the year ended December 31, 2007, consisted of $27.7 million in compensation and benefits, which includes $4.9 million in non-cash compensation, $5.5 million in professional fees and technology services, $5.6 million in facility costs, $2.7 million in travel expenses, $2.3 in insurance and other corporate expenses, $0.3 million in product endorsement and marketing, $3.7 million in other, which includes $1.7 million in recruitment and temporary help, and $6.2 million in depreciation and amortization.
In October 2009, we entered into an amended agreement with our primary commercial bank to extend and increase our secured revolving credit facility. This new facility is for a three-year term expiring October 2012 and has been increased to $100.0 million. This new facility bears interest at LIBOR plus a variable margin based on our ratio of funded debt to EBITDA, payable in arrears on the first day of each month. This new facility is collateralized by substantially all of our assets and contains affirmative and negative covenants, including those related to indebtedness and EBITDA. There were no outstanding balances on this $100.0 million facility at December 31, 2009.
Our operating activities generated $78.6 million of cash from operations in 2008, a $24.0 million increase from the $54.6 million generated in 2007. This $78.6 million in cash provided by operating activities in 2008 reflects $50.4 million in net income attributable to the Company, plus $17.4 million in non-cash charges and $10.8 million net increase in working capital and other assets and liabilities. This $10.8 million net increase in working capital was primarily due to a $49.5 million change in accounts receivable offset by a $58.3 million change in accounts payable and other current liabilities. The changes in accounts receivable and accounts payable were primarily due to increases in our claims volume.
The following table reflects our current contractual commitments as of December 31, 2009 (in thousands):