BOSTON (CBS) – The man accused of murdering two doctors inside their South Boston penthouse likely avoided the threat of deportation last year when he agreed to a plea deal for two different bank robberies.

According to court documents and an audio recording reviewed by WBZ-TV, Bampumim Teixeira’s punishment for those crimes allowed him to keep his green card and skirt federal immigration laws.

Teixeira admitted to robbing the same Citizens Bank twice – once in 2014 and later in the summer of 2016. At his hearing in September, prosecution and defense attorneys made a joint motion for a 364-day jail sentence.

The length of the sentence is significant because a punishment of a year or more in jail qualifies as an “aggravated felony” that would’ve made Teixeira deportable, immigration law experts told WBZ.

But his punishment fell a day short.

Immigration attorney Marisa DeFranco calls it a loophole in the federal law.

“It’s a tactic used by defense attorneys to prevent immigration consequences to somebody’s convictions,” she told WBZ-TV.

During the hearing, attorneys also amended the charges from unarmed bank robberies to less severe convictions of “larceny from a person.”

Those two convictions could’ve still been grounds for deportation because they are considered “crimes of moral turpitude,” immigration law experts explained.

However, there was another important distinction: the earlier 2014 robbery case was resolved as “guilty filed” and the judge only imposed a sentence on the 2016 incident.

In the eyes of federal immigration law, the “guilty filed” disposition does not constitute grounds for deportation.

In an audio recording of the plea hearing, there is little discussion about the sentence. Judge Lisa Grant included a warning about deportation consequences as part of the items she is required to read to defendants who are pleading guilty.

“I’m required to tell you, sir, that if you’re not a citizen of the United States, the acceptance by this court of your plea of guilty may have the consequences of deportation, exclusion from admission, or denial of naturalization,” Grant instructed Teixeira.

Teixeira’s defense attorney, Steven Sack, declined to answer questions about factors that might’ve played a role in his client’s plea deal.

Jake Wark, a spokesman for the Suffolk District Attorney, told WBZ-TV the sentence was appropriate based on the facts of the unarmed robbery cases and Teixeira’s lack of any previous criminal history. He described Teixeira as a legal permanent resident of the United States since 2010.

“No plea in any criminal case automatically results in a person being deported,” Wark wrote in an email. “In fact, federal immigration law is so complex and variable that state prosecutors strive to focus our work on accountability in Massachusetts courts, where, for this defendant, they obtained a nine-month committed sentence followed by three years of court supervision on a case that involved no weapon, no actual use of force, and no injuries.”

Wark went on to write, “This sort of speculation only serves to detract responsibility for two murders from the only individual responsible for them – Bampumim Teixeira.”

DeFranco said the tragic case still has many unanswered questions.

“He still may have been deportable even though his savvy attorney figured out a loophole. Other analyses need to be done and that’s ICE’s jurisdiction,” she said.

An ICE spokesman would only tell WBZ that the agency has no legal role in the matter at this time.

“However, we’ll continue to monitor the case as it develops and should this person be convicted, ICE may have a role in the future,” he said.