S
ources and Uses of Cash.
The following table summarizes our cash flows from operating, investing and financing activities (in thousands):
| | | | | | | | |
| | Three Months Ended March 31, | |
| | 2022 | | | 2021 | |
Net cash provided by (used in) operating activities | | $ | 73,879 | | | $ | (142,574 | ) |
Net cash used in investing activities | | | (22,288 | ) | | | (57,800 | ) |
Net cash (used in) provided by financing activities | | | (77,456 | ) | | | 86,894 | |
| | | | | | | | |
Net decrease in cash and cash equivalents | | $ | (25,865 | ) | | $ | (113,480 | ) |
| | | | | | | | |
Operating Activities
Cash provided by operations was $73.9 million during the 2022 quarter compared to cash used in operations of $142.6 million during the 2021 quarter. The increase of $216.5 million in cash provided by operating activities in the 2022 quarter compared to the 2021 quarter was primarily due to an increase in net sales at Trex Residential and higher collection of accounts receivables in the 2022 quarter compared to the 2021 quarter.
Investing Activities
Capital expenditures in the 2022 quarter were $22.3 million at Trex Residential, primarily related to cost reduction initiatives, the new Arkansas manufacturing facility, capacity expansion in our existing facilities, and safety, environmental and general support.
Financing Activities
Net cash used in financing activities of $77.5 million in the 2022 quarter consisted primarily of repurchases of our common stock of $77.9 million.
Stock Repurchase Program.
On February 16, 2018, the Trex Board of Directors adopted a stock repurchase program of up to 11.6 million shares of its outstanding common stock (Stock Repurchase Program). As of March 31, 2022, the Company has repurchased 4.4 million shares under the Stock Repurchase Program.
Our Fourth Amended and Restated Credit Agreement (Fourth Amended Credit Agreement) provides us with revolving loan capacity in a collective maximum principal amount of $250 million from January 1 through June 30 of each year, and a maximum principal amount of $200 million from July 1 through December 31 of each year throughout the term, which ends November 5, 2024.
On May 26, 2020, the Company entered into a First Amendment to the Original Credit Agreement (the First Amendment) to provide for an additional $100 million line of credit. As a matter of convenience, the parties incorporated the amendments to the Original Credit Agreement made by the First Amendment into a new Fourth Amended and Restated Credit Agreement (New Credit Agreement). In the New Credit Agreement, the revolving commitments under the Original Credit Agreement are referred to as Revolving A Commitments and the new $100 million line of credit is referred to as Revolving B Commitments. In the New Credit Agreement, all of the material terms and conditions related to the original line of credit (Revolving A Commitments) remain unchanged from the Original Credit Agreement.
The Company entered into the First Amendment, as borrower; Trex Commercial Products, Inc. (TCP), as guarantor; Bank of America, N.A. (BOA), as a Lender, Administrative Agent, Swing Line Lender and L/C Issuer; and certain other lenders including Wells Fargo Bank, N.A. (Wells Fargo), who is also Syndication Agent; Truist Bank (Truist); and Regions Bank (Regions) (each, a Lender and collectively, the Lenders), arranged by BofA Securities, Inc. as Sole Lead Arranger and Sole Bookrunner. The First Amendment further provides that the New Credit Agreement is amended and restated by changing Schedule 2.01 to add applicable Lender percentages related to the Revolving B Commitment for BOA of 47.5%, Well Fargo of 28.0% and Regions of 24.5%.
At March 31, 2022, we had no outstanding borrowings under the revolving credit facilities and borrowing capacity under the facilities of $350 million.
Compliance with Debt Covenants.
Pursuant to the terms of the Fourth Amended Credit Agreement, the Company is subject to certain loan compliance covenants. The Company was in compliance with all covenants as of March 31, 2022. Failure to comply with the financial covenants could be considered a default of repayment obligations and, among other remedies, could accelerate payment of any amounts outstanding.
22