Wimbledon champion Novak Djokovic made it harder than it had to be, but rediscovered his poise in time to pull off a four-set victory over Tennys Sandgren at the US Open on Thursday.
Djokovic, winner of the title in Flushing Meadows in 2011 and 2015, defeated the 61st-ranked American 6-1, 6-3, 6-7 (2/7), 6-2.
"It was just me being me - the other me that my first me doesn't like," Djokovic said of the loss of concentration that cost him the third set.
"I thought I played very well for the first two and a half sets and then I just lost it mentally," said Djokovic, who had saved two break points in the opening set and was never in danger in the second.
"I got pissed off or something - at myself, my game or something. I'm not happy with the way I lost that concentration and composure there, but at the end of the day I managed to kind of regroup in the fourth."
With Djokovic suddenly struggling, more of the entertaining rallies went Sandgren's way in the third set and he broke Djokovic for a 3-2 lead.
Djokovic promptly broke back, and had a match point against the American's serve in the 10th game.
But he couldn't convert and it was Sandgren - who put together a sparkling quarter-final run at the Australian Open in January - who seized control in the tiebreaker, speeding to a 3-0 lead and claiming the set on his second opportunity.
Djokovic regained control with a quick break for a 2-1 lead in the fourth. He broke again for 5-2 and clinched the win on his second match point when he patted a ball just out of Sandgren's reach.
Djokovic will take on 26th-seeded Richard Gasquet of France for a place in the last 16.
The 31-year-old Serb, who missed last year's US Open as he battled an elbow injury that finally required surgery, broke out of a prolonged slump with his 13th Grand Slam title at Wimbledon.
He followed that up with a victory over Roger Federer in the Cincinnati Masters final - both victories that he wasn't expecting when he joined forces again with his old coach Marian Vajda with the aim of rounding into form in time for the last Grand Slam of the year.
"It's a work in progress still," said Djokovic, seeded a modest sixth.
"We are working daily on trying to perfect the game and put it together. Obviously the last couple months have been really, really good in terms of results. But we both still feel that I have lots of room for improvement."