Lawmakers negotiating to end the border wall impasse and prevent another government shutdown narrowed their differences Thursday to two key sticking points — the wall itself and the number of beds the government would fund to detain unauthorized migrants.

The two issues moved in tandem, with Democrats offering more money for border barriers in exchange for fewer detention beds. Democrats are trying to limit the Trump administration’s ability to detain border crossers, preferring alternatives such as ankle bracelets. Republican negotiators are in favor of both more barrier funding and expanded detention centers.

It’s not yet clear what the deal will contain as far as physical barriers at the border, and Trump has been inconsistent in describing what type of structure would qualify as a wall.

Negotiators hope to finalize a deal over the next several days, in time to unveil it officially by Monday and ensure House and Senate passage by the Feb. 15 deadline when government funding will run out. A lapse in funding would precipitate another shutdown, three weeks after the last one ended on its 35th day.

Lawmakers of both parties voiced cautious optimism. President Trump, whose demands for $5.7 billion for U.S.-Mexico border walls precipitated the earlier standoff, met in the morning with Senate Appropriations Chairman Richard C. Shelby (R-Ala.) and later sounded a relatively positive note about the negotiations — which the president had previously dismissed as a “waste of time.”

“We’ll see what happens, but I certainly hear they’re working on something, and both sides are moving along,” Trump told reporters in the Oval Office. “We’ll see what happens. We need border security. We have to have it. It’s not an option. Let’s see what happens.”

Shelby said that Trump had laid out his expectations for a deal, and the senator expressed confidence that if those are met, Trump would be able to support a compromise that emerges from the bipartisan congressional committee working on the issue. That seemed to lift some of the uncertainty surrounding the proceedings, since before Thursday, lawmakers had been proceeding without an understanding of what Trump could support.

“If we can work within some of the parameters that we talked about today — that we’ll keep to ourselves — I think he would sign it,” Shelby said. “And I think he’s, from my perspective, been quite reasonable.”

In a sign that lawmakers were closing in on a compromise that could include tough trade-offs for both sides, Rep. Lucille Roybal-Allard (D-Calif.), a key negotiator, told reporters Thursday that it was possible a sizable number of Democrats would be unable to support the final product.

Roybal-Allard said that agencies like U.S. Immigration and Customs Enforcement, which some on the left want to eliminate, serve a legitimate purpose — and that demands from some liberals for no money at all for border barriers would not be met.

“It is unrealistic,” Roybal-Allard said. “If the Republicans and the White House are saying they need barriers, wall, whatever you want to call it, and that is an absolute objective, and we’re saying we want some other things — like in anything else, you know, it’s a trade-off. So, that’s all I can tell you. It’s a trade-off. We’re negotiating.”

For Democrats, a key objective in the talks is reducing the funding for ICE detention beds, which would limit the agency’s ability to aggressively detain unauthorized immigrants, a practice that has angered the party. Current funding levels allow for 40,520 detention beds; Democrats are trying to limit that figure to 35,520 for the remainder of the 2019 budget year, while also increasing funding for detention alternatives. These involve programs that monitor immigrants in various ways to ensure they appear for court hearings, without requiring their detention.

“That’s the area we need to focus on, more transparency, making sure that these detention centers aren’t allowed to abuse people, as we’ve all read,” Roybal-Allard said.

The limits on detention beds that Democrats support have become a key trade-off in exchange for agreeing to additional funding for new border barriers, which Democrats have spoken of mostly in terms of fencing rather than walls. It remained uncertain Thursday exactly how that balance would be struck, but leaders in both parties said they could envision a compromise that would win support from lawmakers on both sides.

“If the bill addresses the main problems that the president’s been discussing since the beginning — the things we need to secure the border that run the gamut from ports-of-entry enhancements to more tools for our Border Patrol agents, more technology and physical barriers that include a wall — I think most of our members would support that, and I think most Democrats could support that, too,” House Minority Whip Steve Scalise (R-La.) told reporters.

Key federal agencies are operating on a short-term spending bill Trump signed Jan. 25, when he relented on his demands for wall funding to end the nation’s longest government shutdown. He gave lawmakers three weeks, threatening another shutdown or a national emergency declaration if they don’t deliver.

Despite the signs of progress in negotiations, the White House continued to explore how to work around Congress to build a border wall if the talks fall through or fail to produce a deal Trump likes.

Acting chief of staff Mick Mulvaney said the White House is looking at ways to redirect taxpayer money for the construction of a wall and is prioritizing strategies that wouldn’t be blocked in court.

“There’s a couple of different ways we can do it,” Mulvaney said Wednesday evening on Fox News. “We’re looking at all of them.”

Mulvaney said the steps would come through some type of executive action. He didn’t specify whether that would require declaring a national emergency, which Trump has threatened for weeks despite opposition from his own party — or if there was another mechanism that might prove less controversial.

Mulvaney said the White House’s preference was for Congress to approve the wall funding, but he said the administration is finalizing plans for how it would act if lawmakers refuse and had already identified “substantially more than $5.7 billion” that could be redirected for these purposes.

House Speaker Nancy Pelosi (D-Calif.) warned the administration against trying to circumvent Congress in this way. “That would not be a very good idea. It would not be a good idea to even try,” Pelosi said.

It is legally difficult for the White House to move money that was appropriated for one purpose and spend it on something else, which is one reason Trump has pushed Congress to authorize construction of the wall. Mulvaney and other White House officials have said for weeks they believe they have ways to do it, but they haven’t specified how it might work, particularly if they do not declare a national emergency.

As a candidate and earlier in his presidency, Trump promised more than 200 times that the wall would be paid for by Mexico.

Congressional leaders in December reached a deal to keep the government open, which the Senate approved by unanimous consent. But Trump rejected the deal, which did not include any money for a wall, starting a shutdown that lasted 35 days and was the longest in U.S. history.

Even as they expressed optimism that a deal could be reached to avoid another shutdown, lawmakers made clear that nothing is certain yet.

“There’s a small light at the end of the tunnel,” said Sen. Pat Roberts (R-Kan.). “We’ll just hope it’s not a train coming the other way.”

Mike DeBonis contributed to this report.