Most of us have been there at some point in our lives: we lose track of our bank account balance and overspend. Suddenly, we’re unable to avoid costly overdraft fees.

When we are using that handy debit card to go grocery shopping, fund those one-click purchases on our Amazon account, and pay bills over the phone, it’s easy to lose track of cash flow. If your bank offers overdraft protection and your account goes into the red (is overdrawn), the bank will be kind enough to cover the charge… for a price.

Beginning in late 2010, the Federal Reserve banned banks from automatically enrolling customers in overdraft protection for cash withdrawals or debit card purchases. If you’ve been with your same bank for a while, you’ve probably received a letter looking for you to “opt-in” to the overdraft plan or to sign that you are aware of the new overdraft regulations. When signing up for a new bank account, you were probably asked to check a box in order to opt-in.

Related: What to Do When You Can’t Open a New Account

So, what happens if you don’t opt-in and agree to overdraft protection? If you swipe your debit card for a purchase when you don’t have enough money to cover it?

Well, that will result in your card being declined (instead of your bank covering it). Then the bank may charge you a non-sufficient funds (NSF) fee.

If you are opted in for overdraft protection, though, your bank will approve the charge, up to a certain amount. The catch is that they will then charge you between $20 and $35 for an overdraft fee.

Either way, you likely get charged a fee. But you might prefer to pay the overdraft fee rather than face the possible embarrassment of having your card declined in the check-out line. However, you can take a few steps in order to prevent these overdraft fees from ever eating away at your hard-earned cash.

1. Use Your Check Register Religiously

The most obvious method to avoid overdraft fees is to spend less than you have available.

We know this, of course. However, thanks to electronic banking, it can become difficult to keep track of direct deposits, debit card transactions, automatic payments, and checks that haven’t cleared. With all the electronic transactions and payments coming into and going out from your account, it can be easy to just sit back and let it happen.

This is where you get into trouble.

Trying to keep a mental tally of your account is probably not a good idea. Depending what shows online or on your bank’s app, you may not get a true representation of your available balance. You could have checks which haven’t cleared, debit card transactions that haven’t hit your account, and automatic bill payments that haven’t yet processed.

Although you may not actively initiate each of your deposits or withdrawals, you should still keep an accurate check register. In this, you should indicate all incoming and outgoing funds, so you can see how much money you actually have. Keeping track of your cash flow is single-handedly the most helpful step you can take to avoid overdraft fees.

2. Link Your Savings and Checking Accounts

Some banks allow you to connect your savings account to your checking account in order to avoid paying overdraft fees. Your linked savings account becomes like a line of credit, giving your checking account a buffer. If you make a purchase that drains your checking account, your bank automatically pulls from savings to cover the purchase.

Note that while you won’t get hit with a $30 or $35 overdraft fee, some banks will still charge for this courtesy service.

From what I’ve seen, the cost is usually around $10 each time you have to tap into your savings account. The fee is considerably less than paying the higher overdraft fees to the bank, though. This is especially true if you overdraw your account and have a number of small charges come in at once.

Let’s say you’re overdrawn by $5 when you log in this morning…

Suddenly, an earlier debit from the coffee shop ($5.41) comes in. Then, ones from the post office ($3.55) and the pet store ($8.99) post minutes later. With traditional accounts, that sudden $17.95 in past purchases would have just earned you three overdraft charges. It would have cost you somewhere between $75 and $105 in fees alone.

However, if you utilize a savings account buffer, your bank would automatically transfer around $20. This would cover all three posted debits, and the bank would charge you a flat fee of $10.

You’ve just saved a ton of money.

The drawback is that it becomes more tempting to spend money from your savings account when your checking account is low. If you do decide to link a savings account with your checking account to avoid overdrafts, it’s recommended you keep yet another savings account somewhere else. Fund the linked account with just enough money to fund this overdraft buffer. Then keep your “true” savings at a different bank.

Or, you should at least keep it in an account that is not connected to your checking account. Then, you can use that account for long-term savings without the temptation of drawing from it when you overspend.

Related: The 4 Types of Savings Accounts That Everyone Should Have

3. Set Up a Safety Net Account

What if your bank doesn’t offer an automatic savings transfer option?

Well, you can still create a manual version for yourself. Simply set up a linked account at the same bank, and fund it with buffer cash.

Most banks allow you to create a number of sub-accounts free of charge. These may be additional checking accounts or savings accounts, but they are automatically linked to your primary checking account. Name it Safety Net Account, and fund it with however much of a buffer you think you need.

Then, if money gets too tight and you know you’ll overdraw, you can quickly transfer money to cover the overage.

These transfers are often immediate, posting to the receiving account in a matter of seconds (even after business hours). Once you get paid or are again in the black, transfer that money back into savings.

This method is free (no courtesy transfer fees from your bank). But it does require you to keep an eye on the account and catch those potential overdraws before they happen. Luckily, you should be doing that anyway!

Resource: Top 3 Online Savings Accounts for Kids

4. Set Up Alerts

Most banks allow you to choose from a number of account alerts meant to allow you to avoid unexpected debits or overdraft fees.

For instance, I use Capital One 360 and am enrolled in all sorts of optional account warnings. These include:

low balance alerts — set your own threshold, and receive email alerts when your account drops below that amount.

set your own threshold, and receive email alerts when your account drops below that amount. spending limit alerts — set your own threshold (above $1), and receive email alerts anytime a transaction posts to the account that is higher than the set limit.

set your own threshold (above $1), and receive email alerts anytime a transaction posts to the account that is higher than the set limit. external withdrawal alerts — anytime a transaction comes through that does not involve a card being swiped, you can receive an email alert. This is handy for subscriptions, automatic BillPay, or online purchases (such as those Amazon one-click orders at midnight), which you may have forgotten about.

5. Request a Courtesy Refund

No, this method won’t help you avoid the fees in the first place. However, it’s still better than forking over $25-$35 to your banking institution.

If all other efforts fail and you either don’t catch a cash flow issue, have an unexpected charge, or just run low on cash one month, you may not be able to stop an overdraft.

Well lucky for you, most banks are kind enough to refund as many as one overdraft fee a year. All you have to do is call and ask.

Get on the phone with customer service, and kindly ask if they can waive the fee. If you’ve never had a fee refunded (or one reversed in the last 12 months), they will likely post a credit to your account.

Don’t make a habit of this, as banks will rarely do it more than once a year. However, it’s worth a shot to ask if all else fails, especially the first time around. The worst they can do is say, “No.”

Learn More: 5 Ways to Automate Your Finances

Overdrawing your account is stressful enough. Your bank’s hefty fees on top of it can be the bitter icing on the cake.

Avoiding these fees can sometimes be easier said than done. However, with a few safeguards and a little extra cash flow tracking, you can quickly be on your way to staying in the black — and in the clear of fees.

Do you have any other tips for making sure you don’t get hit with overdraft fees? Share them below!