Hong Kong courts rule according to law rather than government's preference or public opinion. From time to time, our judges overturn policies and legislation that are deemed unconstitutional. Although their decisions may upset the community and bring far-reaching consequences, it is important people respect the outcome. In a landmark ruling on Tuesday, the Court of Final Appeal struck down the seven-year residency rule for immigrants to qualify for comprehensive social-security payments. If the initial reaction on social media is anything to go by, the decision has not been well received. It stokes fears of more new arrivals queuing up for the dole and possibly public housing and other benefits. But the rule of law must not be overruled by emotions. The residency rule was lengthened from one year to seven in 2004 amid growing concern over the long-term financial burden of providing the benefit. But the top court ruled that the new requirement was unreasonable and had infringed on a citizen's right to social welfare enshrined in the Basic Law. The court also rejected the government's explanation that the tightened restriction made the system more sustainable, saying it conflicted with the policy of family reunion under the one-way-permit scheme and the aim to rejuvenate the ageing population with immigrants. To avoid further legal challenge, officials should thoroughly review the existing measures and policies to ensure they fulfil legal requirements. The additional cost to taxpayers from the ruling is unclear; estimates range from HK$300 million to HK$1.8 billion. As the court pointed out, the saving is not proportional to the curbs imposed on individuals' constitutional rights. The amount only accounts for a small percentage of the multibillion-dollar pay cheque for welfare recipients each year. With new arrivals limited to 150 a day, it would be wrong to say the ruling will lead to an influx of mainlanders. Government figures show the director of welfare had already exercised discretion to approve 14,000 of the 36,000 applications filed by immigrants over the past decade who did not meet the seven-year rule. Moreover, applicants will still be bound by the one-year rule. The cost arising from the change does not appear to be unbearable. The ruling indeed helps make our welfare system fair and just. Instead of cold-shouldering those who have chosen to settle here, we should be more accommodating.