Let’s say you’re looking to buy a home with your family, so you apply for a mortgage. Your finances aren’t perfect, but you have a respectable credit score, a steady income and you’re asking for a reasonable amount. You talk to a bank representative, go through the application process and wait patiently. Everything seems to be in order, and you feel pretty confident.

Then you get a rejection letter.

How did this happen? Did you misunderstand the requirements or make an error during the application process? Did you inadvertently tick off someone at the bank? Did the bank somehow reject the wrong application? You call the bank representative you talked to and they lay it out for you – that credit card you applied for shortly after filling out the mortgage application disqualifies you from the loan.

Situations like these are so frustrating, but so avoidable if you do some research. Borrowing is a delicate process, and making even a tiny misstep could spook the lender into reneging. Think of it from their perspective – even if you had the money, would you lend out hundreds of thousands of dollars to someone you weren’t completely certain was going to pay you back?

Don’t get tripped up the next time you’re looking to borrow. Read ahead for the do’s and don’ts of applying for a loan.

Have at least two year’s tax returns if self-employed

Plenty of well-earning self-employed people have found that their income counts differently than their W2-receiving peers. Lenders view variable income differently, because it can fluctuate depending on the time of year and the industry you’re in. In their eyes, it’s much easier to lose a few clients than it is for one person to lose their traditional job.

Before you apply for a mortgage or other type of loan, talk to a lender about what you need to do as a self-employed person. Most banks want to see at least two year’s of taxes showing self-employed income and that your income has increased or at least remained steady.

Remember, banks will only look at your net income, not your gross. This matters because if you’re self-employed you’re likely taking as many tax deductions as possible to reduce your taxable income. Unfortunately, lenders don’t include those deductions when they’re deciding how much to lend you. If you decide to apply for a loan, then it might be worth taking fewer deductions so you can show a bigger income.

Be aware of credit inquiries

In the days before the Great Recession, mortgages were given out like candy. Lenders could authorize a $300,000 home for a couple making $60,000 a year combined.

Now, banks are more careful about who they give money to and how much they let you borrow. One way they determine that is by checking your credit report. A credit score of 580-620 is the basic requirement to qualify for a mortgage, but a score of 760 or higher will get you the lowest interest rates.

One possible reason that a lender won’t give you the best rate is if you have too many recent credit inquiries. Hard inquiries are the ones you get when a lender checks your credit report after you’ve applied for a loan. They stay on your credit report for two years and affect your credit for the first year, while also affecting your credit score.

It might be tempting to apply for a new credit card or auto loan, but if you’re about to take out a major loan, like a mortgage, then put everything on the back burner until the loan is approved. In general, if you know you’re going to apply for new credit, then avoid hard inquiries for at least one year prior.

Don’t cosign for someone else

Cosigning for someone has a direct impact on your ability to get a mortgage, as the loan will now show up on your credit report as well as theirs. Even if you have no other form of debt, cosigning for your sister’s $30,000 student loans will affect your credit report as though you borrowed $30,000.

If you’re considering buying a home, you should say no when someone asks you to cosign for a loan. Maybe it will help them in the short term, but your credit will be negatively affected until they pay off the debt – which can take years. Realistically, cosigning on a loan is almost never a good idea.

Don’t quit your job

Just as being self-employed affects your loan application, so does having an unstable employment history. Switching jobs can affect your ability to get a loan. While some people try to avoid this by lying on their application, you should be aware that this is considered mortgage fraud and can result in your application being denied.

Stick with your job at least until after the loan has gone through and you’ve got the keys in hand, so you don’t lose your house at the last minute.

Mortgage advisor Casey Fleming, author of “The Loan Guide: How to Get the Best Possible Mortgage,” said people should even be wary of switching from a salary-based position to a commission-based one, even if it’s at the same company.

Commissions come and go, and if you have no employment history as a commission-based employee, lenders will be concerned that you can’t handle the payments if sales decline. Like those who are self-employed, people who primarily earn a living through commissions will need to provide two years of tax returns to demonstrate their financial standing.

Don’t go on a shopping spree

Buying a home triggers a nesting response in a lot of people, especially if it’s their first home. If you’re about to buy a house, then you probably need to buy appliances, furniture, decorations and more.

But before you swipe your credit card on that entertainment center, beware. Lenders frown on people racking up debt suddenly, even if they plan to pay it off. They want to know that you’re a stable borrower who doesn’t make impulse purchases. They also want to see that you have a good supply of cash waiting on hand before you buy a house, since even a small repair can cost thousands of dollars.

Wait until the mortgage is completely final before you buy anything huge, especially if you’re using a credit card to finance it. At the very least, make sure you have a solid emergency fund that won’t be affected if you buy a washer and dryer set.

“Essentially, don’t change your financial situation until after you close,” Fleming said.

Document all large deposits

Just as spending a lot of money suddenly looks bad to a lender, so does receiving a sudden influx of cash with no documentation of it. If it’s a check from your grandparents that you received because they want to assist with your down payment, that’s one thing. But a $3,000 cash deposit into your account two weeks before your application? That will cause some red flags.

That’s because they can assume a cash deposit means you borrowed some money from a friend or family member to make it seem like your financial position is stronger than it really is. If you borrow $5,000 from your aunt for a down payment and tell the loan officer it was a gift, you’ll make it seem like you’re a better loan candidate than you really are. Plus, not declaring your debts to a mortgage lender is another example of mortgage fraud.

If you made a large cash deposit recently or plan to make one soon, provide as much documentation as possible. For example, if you sold your old beater on Craigslist for $2,000, make sure to keep a copy of the bill of sale.

Make your social media private

While it’s a relatively recent approach that isn’t being used by all lenders, many are starting to survey their applicants’ social media in order to further ensure their trustworthiness as a borrower. That may sound unfair, but it’s the age we live in – and more lenders will probably adopt the tactic in coming years.

If you’d rather not make your social media private for business or personal reasons, make sure your accounts show no hint of fiscal irresponsibility. These signs could include making frequent impulse purchases, showing signs of career instability or even displaying a volatile disposition.

The bottom line

Buying your first home isn’t like renting an apartment, where you can see the place, sign a lease and be moved in within the week. It can take at least 30 days from putting in an offer and closing. It can also be an incredibly frustrating process, full of details and questions you never wondered about.

Be prepared for delays, paperwork and headaches that you haven’t experienced before. Comply with any questions the lender has and be sure to document everything. And before you put an offer down, think about if the home is right for you. There’s no sense in going through all the work if you’ll be selling it within a few years.