A few years ago, InMobi’s success was uncertain.

The mobile advertising platform’s hiring and firing practices drew scrutiny. Worryingly, investors have kept a distance—its last funding round was in 2011—and some of its biggest bets didn’t pay off. For instance, its 2015 launch of Miip, which engaged users by suggesting products to buy across apps, was discontinued within a year, eroding the company’s confidence. Also, in 2016, several mid- and top-level employees also deserted the company.

Yet, last year, while others posted massive losses, India’s first unicorn scored a big win.

On April 05, InMobi—which was founded in 2007— became the second billion-dollar startup from the country (after data analytics firm Mu Sigma) to declare profitability. It logged a profit of around $10 million in the last quarter (October-December) of 2016 (the company’s financial year is the calender year). The Softbank-backed ad-tech firm expects the streak to continue through 2017 and beyond.

So how exactly did it manage to turn around? Quartz spoke to InMobi co-founder and CEO Naveen Tewari in San Francisco about this. Here are the edited excerpts.

Did you expect to be profitable at the end of 2016?

It’s an interesting time for us because we are dealing in a space which has been massacred for the past few years. We weren’t expecting profitability in 2016. We thought 2017 [was aspirational] and definitively 2018 (would be profitable).

What did your path to profitability look like?

What has really worked well for us is, one, our investments in China (which accounts for 28% of revenues, second only to the US market, which rakes in 30% of overall revenues.) Obviously, Google and Facebook are not there so that makes it easier. We’re the second largest ad platform there after WeChat.

Second, was our massive focus on video ad (Video ad revenue quadrupled compared to the year prior).

Third was more fiscal discipline. As a company, you kind of transition yourself from a classic startup to a more mature company in the way you run your things. [It’s] damn boring but that actually delivers a lot of results. So we did a lot of that to ensure every dollar gets accounted for rightly, every deal is accounted for rightly.

We also gain because we’re the only product company that’s not out of the US. We’re out of India and so we have similar quality talent but at a fourth of the price. So you can actually really do high quality innovation at lower price points. Therefore, your innovation productivity index is really high, significantly higher than companies in the Bay Area or elsewhere.

What are some of the challenges you faced?

About four years ago, we were struggling with our culture a lot. We started to lose people. And so, at that time, we focused a lot on fixing and building a culture for the company.

Today, we’re very proud of the fact that people stay because they love the culture. Attrition is extremely low. At the end of 2017, 25% to 28% of the company (staff) would be five-plus-years old. That means, of our 900-people company, about 225 odd people would have spent more than five years. Five years ago, our strength was only 400-500 people so it’s almost like 50% of people have stayed. Some 90% of the exec team members [have been with us] for over five years.

How does being profitable impact your future goals?

You can articulate a bigger play for yourself over the next several years. We’re embarking on a few more ambitious plans. You can say that whatever we were doing until now is secure and that it makes money. I can now embark on two-three things which will take some losses but which I can fund it through here (the profits).

Do you have any plans to go public?

In the next two-to-three years, yes, for sure.

How will that change the way the company works?

There are always challenges. How do you manage the public markets? You can’t take as many risks as you were planning to earlier. So yes, those are things that we have to fix somehow.

What’s your take on other B2B companies in the sector?

I’m a big, big fan of B2B companies. They’re less glorious but they absolutely have solid business models, high margins, and they can scale really well.

B2C companies are struggling in the way they projected what the consumer base for them would look like because of two factors: One, I don’t think they’ve figured out the unit level economies and, second, I think they’ve all somewhere misunderstood the size of the market. If you ask me how big is India, I wouldn’t say its 1.2 billion people. I would say it’s 27 million people with a GDP per capita of $10,000. That’s less than Australia, where people have GDP (per capita) $50,000 dollars.

When should a startup look to turn a profit?

I don’t know whether there is any [specific] time for it…I just think it’s a change in mindset and discipline and that has to happen at some point of time. I think profitability is always about profitability at scale and not profitability at a low scale. Low scale profitability—if that hampers your longer term scale, then its not right.

Like you cross the seven-year mark in the loss-making zone, it’s too much.

Half knowledge is bad and I think that’s what happens. People pick this phrase and say “hey, we should not be profitable” but they don’t understand why you should not be profitable. To me, that’s just dangerous fashion versus true business building. Like businesses are built on free cash flows. [You’re] not necessarily required to do it in the first few years, granted. But eventually you need to know how you get there and if you cannot know how you get there, then you have a big challenge.

Like you cross the seven-year mark in the loss-making zone, it’s too much.

So, what is InMobi’s next play going to be?

[Mobile advertising] is going to be a very, very large market…the ads which are appearing on your mobile devices, the size of that market would be $200 billion. But the mobile ad space doesn’t stop there. The future of mobile ads is [that] because of the data you get on your phones, you can actually impact the ads that appear on your television. So, the mobile ad space is suddenly not $200 billion but $400 billion.

The main participants in this ecosystem till date have been the companies for whom ad monetization is the primary business model…but there is a second wave of industries and companies (telcos, device manufacturers, e-commerce companies) for whom ad-based monetization will be a secondary business model. As they make that change, they cannot do it themselves.

Some of the companies that can help them do this (change) are Google and Facebook. But they (the second-wave companies) will never go to them because, you know, look, there is an anti-Google, anti-Facebook force anyway out there. That leaves the players below these guys—companies that may be in the $100-million-to-a-billion-dollar space. That’s only five to six companies and we’re one of them. Of those five to six companies, only two-to-three are global in nature [like us].