Berlin - Bayern Munich's 3-2 loss at Manchester City on Tuesday could not have come at a better time for coach Pep Guardiola, who said his side would learn from the mistakes that led to a first defeat since August.
Bayern had already secured top spot in Champions League Group E before their trip to Manchester but were 2-1 ahead and still in control of the contest until the 85th minute despite playing with 10 men for most of the match.
However, individual mistakes gifted two goals to the home side in the dying minutes as the English champions rallied for an unexpected victory to keep them in a competition they appeared destined to crash out of in the group stage.
"It is good that this happened here," said Guardiola, who saw Sergio Aguero score all three goals against his usually well-drilled defence, the most they have conceded this season.
Aguero's hat-trick matches the total amount of goals Bayern have shipped in 12 Bundesliga games this season.
"This will be a lesson for us because if something like that happens in the Round of 16 or the quarter-finals then you are out of the competition," the Spaniard said.
Bayern's only previous loss this season was against Borussia Dortmund in the German Super Cup in August, having since stretched their unbeaten run to 18 games until Tuesday.
Despite a string of injuries and changes in his starting lineup with Sebastian Rode and Pierre Hojbjerg earning rare starts, Guardiola was determined to ensure his team made it five wins out of five group games.
Goals from Xabi Alonso and Robert Lewandowski cancelled out an early City penalty as Bayern refused to surrender, before lapses of concentration at the end proved costly with Argentine Aguero scoring twice in six minutes to turn the game.
"We lost and if we lose playing badly, then that is not good. But the team did not deserve to lose. I am very proud of my players." Guardiola said.
"Playing for 70 minutes with 10 men against the English champions takes a lot of effort. We had a lot of personality."
"Twice we lose the ball and twice we were punished," winger Arjen Robben lamented. "It is a real shame because we played really well. We deserved more."
"We can be proud of ourselves because we did not hide. We were strong although we were a man less."