President Barack Obama’s decision to extend U.S. troop presence in Afghanistan is welcome news.

It would have been preferable for him to drop all arbitrary deadlines for withdrawal and commit to keeping the 9,800 U.S. troops in place until a reassessment of the ground situation is taken next year. But this is certainly a step in the right direction.

Obama has announced that the current number of U.S. troops deployed in Afghanistan as part of the NATO Resolute Support mission to train and advise the Afghan forces will remain in the country through most of next year.

In addition, despite his earlier pledge to withdraw all U.S. forces, except those necessary to protect the U.S. Embassy, by the end of 2016, Obama now says a force level of 5,500 U.S. troops will remain in the country when he departs office in January 2017.

Obama has made the right choice in extending the U.S. troop presence in the country. The fall of the northern Afghan city of Kunduz to the Taliban in late September demonstrated that the Afghan security forces continue to need U.S. and NATO support in the form of air strikes, intelligence, training, and battlefield advice.

The Afghan security forces are fighting hard, but they have taken a record level of casualties since the U.S. and NATO ended combat operations last December. Afghan forces have retaken control of Kunduz, but other key urban areas are also under threat from the Taliban.

Perhaps the biggest motivating factor for Obama to reverse his decision on U.S. troops in Afghanistan is the meltdown in Iraq following the rise of ISIS over the last year. U.S. Congress members had increasingly raised their concern that a hasty U.S. withdrawal from Afghanistan could result in Afghan forces facing a similar threat from the Taliban as the Iraqi forces faced from ISIS.

Moreover, there are increasing signs of ISIS gaining a foothold in Afghanistan, particularly in the eastern province of Nangarhar, further complicating the militant landscape and contributing to instability.

Obama also made clear that part of his decision to extend the U.S. troop presence in Afghanistan was based on his confidence in the current National Unity Government led by President Ashraf Ghani and Chief Executive Abdullah Abdullah.

During his remarks at the Heritage Foundation earlier this year, Abdullah expressed his deep appreciation for U.S. support but acknowledged that the ultimate goal is Afghan self-reliance. It is clear that under the current Unity Government, there is a chance to build a more effective and long-lasting U.S.-Afghan partnership to deny global terrorists the opportunity to revive their base of operations in the country.

So there are many good reasons to extend the U.S. troop presence in Afghanistan. It is good to see the president finally come around on it.