THE harassment of the Windrush generation of Caribbean migrants is a shameful chapter in Britain’s history, and ministers are paying for it. One home secretary resigned on April 29th; her predecessor, Theresa May, now the prime minister, is weakened. It falls to Sajid Javid, who took charge of the Home Office this week, to clear up the mess.

There is little to like about Mrs May’s migration policy. The state-led hounding of thousands of law-abiding British citizens was a side-effect of the “hostile environment” for illegal immigrants that she created as home secretary.

Indeed, Mrs May’s rigid insistence on reducing net inflows to the arbitrary level of 100,000 a year created a hostile environment for all migrants, not just the illegal ones (see article). Landlords, employers and others were given new duties to check people’s migration status. The result has been that those with incomplete paperwork have been denied homes, jobs and public services, and have even been locked up. Mrs May sent mobile billboards bearing the legend “GO HOME OR FACE ARREST” to migrant-heavy districts. She ridiculed “citizens of nowhere” and threatened to make companies publish lists of their foreign workers (before backing down). Cowboyish Home Office officials desperate to reach their targets have used any excuse to notch up ejections. Claiming to crack down on illegal migrants, they even broke the law themselves.

For all its shortcomings, Mrs May’s approach does contain one idea that is worth preserving: enforcement should happen inland, not just at the border. Most of Britain’s half-million or so illegal immigrants did not enter the country illicitly but have overstayed their visas. Furthermore, from the camps of Calais to the Mediterranean sea, there is plenty of evidence that fortifying borders does not stop lots of people continuing to try to cross them. The result is migrants’ suffering, extra cost to taxpayers and a bonanza for people-smugglers.

The Windrush debacle highlighted that Britain has no easy way of carrying out this inland enforcement. The government’s guide for landlords who need to verify tenants’ migration status is 35 pages long. If landlords get it wrong they risk a fine or even imprisonment. Researchers have shown that, unsurprisingly, they tend to err on the side of caution, rejecting those without passports (and especially those who are not white). The result is pressure against all migrants, and also against ethnic minorities, British or otherwise. After Brexit the problem will be worse, as 3m Europeans will be allowed to remain permanently but without passports.

The scandal has rightly provoked calls for an overhaul of migration enforcement. Any rethink must get to the root of the problem. This is not that Britain checks the status of migrants, as any country must if it values the rule of law. The real shortcoming is that Britain, rarely among advanced countries, lacks a simple, non-discriminatory way to check the identity of its population. Under Mr Javid it should get one.

Liberals, including this newspaper, have argued against national identity registers on the basis that they invade privacy and aid oppression by the state. But the balance of this trade-off has changed. In a globalised world more people spend time travelling, studying or working abroad, and access to labour markets and public services depends on their exact status. Proving identity thus matters more than ever. Countries like Britain that lack an ID register rely on other proofs—bank statements, tax records, phone bills—that are even more intrusive. As for the risk of oppression, the Windrush affair shows that it is not just all-knowing states that have the power to persecute their citizens. It was precisely the opacity of information that the Home Office exploited in order to pursue many thousands of people who had a right to be in Britain.

Papers please

Setting up an identity register would not be cheap or easy. A previous, abortive effort to roll out ID cards a decade ago was priced at about £5bn ($7bn). It would probably have to involve an element of amnesty for those caught up in a Windrush-style trap of missing paperwork. But Brexit is forcing Britain to think hard about matters of migration and citizenship. Taking back control of who enters the country is one of the biggest prizes advertised by Brexiteers. To do that, Britain must first have a better idea of who is already there.