The Leadership Insider network is an online community where the most thoughtful and influential people in business contribute answers to timely questions about careers and leadership. Today’s answer to the question: What did you learn from your biggest failure? is written by Barry Sanders, managing partner at McChrystal Group.

Thirty years into my career, my father interrupted one of my management stories to ask me a question: “You have been reasonably successful in your career. Are you really that smart or have you just been lucky?”After considering the question, my answer to him was actually both. On the one hand, he passed on some decent genetics in the “smarts department”– my father was a rocket scientist — and I received a decent education to nurture these gifts.

On the other hand, I was lucky enough to receive some great opportunities, progressive performance-based management promotions, and direct exposure to some amazing leaders and mentors. In my career, I have benefited from the collective wisdom of various advisors, from AG Laffley to Dr. Michael Porter to General Stan McChrystal. Each of this individuals have shaped my thinking and personal development on a host of issues from leadership to strategy to the future of management. However, the most formative part of my career didn’t come from my access to these tremendous leaders. The most important lesson I learned was not from the experiences and wisdom of others, but from my own, arising out of a situation that I would characterize as one of my worst performances as a leader.

In 2005, I was leading North American Sales for Scotts Miracle-Gro Company. The company had just announced the acquisition of a small outdoor products retailer in San Francisco called Smith & Hawkin. Our master plan was to turn the company into the outdoor living brand for our organization. The brand was respected and we were a leader in distribution at scale — from mass retailers to the smaller lawn and garden centers. On the surface, it appeared as though we had all the ingredients for success.

See also: How One Bad Employee Can Destroy Your Entire Business

The company decided the best approach would be to put a Scotts executive in to run the operation and transition our most recent acquisition over to our wholesale model. I was asked by Jim Hagedorn (Scotts Chairman and CEO) to take on the leadership role for this project. At first I was hesitant. I enjoyed heading North American Sales and felt I was making an impact. But Jim convinced me that the company needed me to take on this challenge, and made the case that it would be great for my own personal development. As he explained it: If I was successful, it would be net positive for everyone. If I failed – -or as he said it, “got a bloody nose”– it would still be an important learning experience for me. More importantly, it would also give him and the board a chance to see how I responded to failure. Jim advised me that I could never make my way up to the president role within Scott’s until I showed them how I coped with failure, as they had yet to see me fail.

At the time, this advice seemed to be strange commentary, but I nevertheless took it on as a personal challenge. I shipped off to San Francisco to start my new leadership role with Smith & Hawken, prepared to sink or swim. Things started off well, and I very rapidly moved up the learning curve of leading a retail business and trying to convert it into a wholesale model. We were able to put a wholesale agreement in place with @target tgt Target and create a structure to sell product into the restaurant and hospitality industries as well. During the process of converting our acquisition to a wholesaler model, the core business needed to stay stable enough to fund the transition (a critical factor I discounted at the time). Stability was the lynchpin of my strategy, and barring unpredictable events, I was on track to hang my hat on another success.

Enter the financial crisis in 2007. When you’re making a living selling $3,000 teak outdoor dining sets, a souring economy and a tanking housing market is far from a stable environment. My strategy quickly began to unravel. With its core stability undermined, our acquisition dramatically underperformed and the vision of converting it into a wholesaler that could plug into our model was suddenly failing. It seemed as though the only successful action I took was recruiting my replacement, a senior merchant from wmt Walmart.

Ultimately, Jim Hagedorn was able to see how I responded to not succeeding. I must have passed his test, as it did not end my career, as I went on to become president of Scotts Miracle-Gro in 2010. But even if I hadn’t gotten the position, I still learned valuable lessons that I could take anywhere:

  • Always be prepared in case what can go wrong, does; have contingency plans in place and constantly assess the risks.
  • Ensure your team completely understands the plans and has bought into the idea; the collective intelligence of an engaged team far outweighs that of a lone leader.
  • Never be over-confident in your own abilities; approach every opportunity with reservation and humility.

The lessons I learned from this failure are best captured by something I was told by Bob Bernstock, the president of Scotts at the time: you have to understand the difference between the jockey and the horse. A great jockey can never win riding a bad horse.