In this season of high school graduations, many parents are crossing their fingers and hoping they’ve put aside enough money to last the next four years of college tuition. But the timing on these things doesn’t always work out as planned.

It’s not just that a 529 plan may not be enough to cover four years of higher education. Some students and parents may be dealing with a more serious concern: what happens if the students lose their parents halfway through the saving process of a 529?

Other parents may have a different, more fortunate type of concern: thanks to scholarships or tuition costs that came in lower than expected, or kids finishing school early, or investments that performed better than expected, there are 529 plans that end up with too much money in them.

Luckily, both situations can be remedied with a little planning.

For parents, especially older ones, who are worried they won’t be around when the 529 plan comes to fruition, the key is to carefully name a successor to the plan. The successor takes control of the plan’s assets if the parent dies or is otherwise incapacitated. That successor can change pretty much any decision about the money in the plan, including who it should be spent on. So parents need to be especially careful that the successor knows and is willing to carry out their wishes.

See also: Top 30 colleges for highest starting salaries

Without a named successor, the beneficiary takes control of the account upon the owner’s death. While we’d all like to think that person would use the money for college tuition, as intended, it might be nice to ensure the money doesn’t go toward a sports car on the beneficiary’s 16th birthday instead. In addition to blowing his or her college money, that erstwhile student might also be responsible for tax penalties on the 529 assets.

For grandparents who have set up 529 plans for their grandchildren and are worried they may be nearing the end of their life, there is a simple solution. They are entitled to transfer ownership of the account to the child’s parents. It’s also possible to transfer ownership directly to the beneficiary, although this may potentially incur gift taxes. An important protection for many grandparents: if your trust in the child’s parents is less than absolute, the parent does not need to be named as the successor to the plan.

Another safeguard: specify in your will that the executor is to use the 529 money for college tuition as you intended. The value of the 529 will not be considered part of your estate for estate tax purposes.

Much nicer to think about is the opposite scenario, where the money in a 529 plan outlives the designee’s college career. The first choice in such a scenario is obvious: that money can be transferred to a younger child, or a grandchild, or any blood relative, to use for tuition. The account owners can even use it to go back to college themselves.

The account owner can also transfer the money to someone outside the family, but there will be tax issues. Not only will there be federal income tax to pay plus a 10 percent surcharge on the earnings, but the IRS may charge gift tax to the new beneficiary.

But if there isn’t another recipient waiting to use that money — say it was intended for the youngest child in the family — it doesn’t disappear. The account owner can simply take the money as a distribution, although it will incur not just ordinary federal income tax but also that additional 10 percent surcharge on the earnings.

Something else to consider if it looks like you might have 529 funds left over: that money can go for more than tuition. Any required fees or books can also be paid for with 529 funds. In some cases, living expenses may even be covered.

The important thing to stress to your clients is that 529 plans are designed to be flexible. In the worst of times or in the best of times, they always have options to make sure those assets are put to the best possible use.

 

For more on college funding, see:

Net flows into 529 plans highest since 2011

The life insurance college savings bank

4 ways to replace life insurance sales lost due to the fiscal cliff deal