Behold, a unicorn living beneath the Gold Dome: a bipartisan bill that both loosens and tightens restrictions on gun purchases.

Senate Bill 99 is similar to a bill that passed last year, only to be tacked onto an omnibus gun bill that Gov. Nathan Deal vetoed because of other elements (this was a separate bill from the campus-carry bill). The current version is a joint effort by Democrat Elena Parent of Atlanta and Republican Tyler Harper of Ocilla, and it addresses when people who have been involuntarily hospitalized for mental illness or substance-abuse can have their right to purchase firearms restored. The Senate approved it 52-1 earlier this month. It’s now pending before the House.

Federal law requires states to report such involuntary commitments to the FBI for the National Instant Criminal Background Check System, rendering the hospitalized persons ineligible to purchase firearms. Under current state law, that information is automatically expunged five years after the hospitalization — no more, but also no less.

SB 99 would change that in two ways, and we need to get into the weeds a bit to understand how. First, it would allow the person in question, as soon as their hospitalization ends, to petition the court that committed them to have that information expunged from the background check system. The court is to consider a variety of factors and testimony outlined in the bill. If it determines the person most likely poses no danger to himself or others, the records will be expunged. If not, they must wait at least 12 months before submitting a new petition.

But let’s say that, at the end of five years, a person hasn’t successfully petitioned to have the information expunged. Currently, it would be removed automatically at that point. SB 99 also changes that.

Instead, 30 days before the five-year mark, the court will have to decide whether to let the information be expunged or to hold a hearing on the matter. If it holds a hearing, the court must decide whether it is highly probable (a higher standard of proof known as “clear and convincing” evidence) the person poses a threat to himself or others. If so, the information about their hospitalization stays in the database. Otherwise, it’s expunged.

Now let’s take a step back. A history of mental illness is a common factor in many mass shootings in this country. If we’re going to restrict gun rights to address that, we ought to focus only on people who have such a history. This bill won’t address all such people — many people are treated for mental illnesses without being involuntarily hospitalized — but it’s a reasonable refinement of both ends of the process for those it does touch.

Those whose problems have been successfully addressed need not be penalized for longer than is necessary. But those whose problems remain shouldn’t have their penalties ended sooner than is justifiable; to do otherwise is, over time, to erode public support for the Second Amendment. A bill that makes improvements on both counts is a good bill.

Sometimes, bipartisan bills make it through the legislative process because they represent the worst instincts of Republicans and Democrats. This is one of those occasions when it represents the best of both sides.