The Justice Department has approved a mega-merger between CVS pharmacy chain and insurance giant Aetna, but the companies have to divest their prescription drug business on Medicare to complete the transaction.

The department announced the decision on Wednesday. Previously, a major concern on the part of the Justice Department was how the merger will affect competition in Medicare Part D, the program’s prescription drug plan.

Both CVS and Aetna are major competitors on the sale of Part D plans to Medicare beneficiaries.

But those concerns appear to have been abated after Aetna agreed to divest its Medicare Part D business.

“Today’s settlement resolves competition concerns posed by this transaction and preserves competition in the sale of Medicare Part D prescription drug plans for individuals,” said Assistant Attorney General Makan Delrahim of the Justice Department’s Antitrust Division, in a statement.

The Justice Department had worried that the merger would lead to increased prices in the 22 states where Aetna offered Medicare Part D plans.

As part of the settlement, Aetna must divest its Medicare Part D business to the insurer WellCare and “allow WellCare the opportunity to hire key employees who currently operate the business,” the department said in a release.

[Previous coverage: With CVS merger under review, Aetna sells Medicare prescription unit]