A deal was struck between Sears (SHLDQ) and Chairman Eddie Lampert early Wednesday morning to save the company and its roughly 400 store locations.

The now almost $5.2 billion deal came after negotiations with law firm Weil, Gothsal & Manges as Lampert worked to save Sears from bankruptcy through his hedge fund ESL.

The new deal from Lampert could save up to 50,000 jobs as the company was facing liquidation at auction Tuesday. Lambert’s bid was the only one on the table to save Sears from closing for good.

A bankruptcy judge instructed Sears advisors to wrap up the deal with ESL and Lampert, which prompted advisors to work on a solution that came at 2 a.m. on Wednesday, CNBC reported. The new offer from ESL includes an additional $150 million and the assumption of more liabilities, according to Reuters.

However, despite Lampert securing the deal to save Sears, the company’s unsecured creditors are not satisfied with the bid, the CNBC reported. The unsecured creditors can still object to the bid, which would require a bankruptcy judge to intervene on Jan. 31. A bankruptcy judge needs to sign off on the deal for it to finally become official.

Sear’s, which has not turned a profit since 2010, still has an uphill battle as it needs to figure out a strategy to remedy its business revenue issues. It is unknown if Lampert’s deal will save the 425 Sears and Kmart stores that remain open.

Sears filed for bankruptcy in October and after rejecting Lampert’s first bid of $4.4 million gave the chairman time to submit a more substantial offer to help the company emerge from bankruptcy.

As of 12:11 p.m. ET, Sears stock was up 45.45 percent.