Stuart Hogg conceded Scotland were fortunate to come away from their final Six Nations match with victory over bottom side Italy.
Scotland claimed a bonus-point win at Murrayfield to all but secure third place, bar a bonus-point win and a huge margin of victory for England against Grand Slam-hunting Ireland later on Saturday.
While the 26-14 scoreline may suggest the hosts dominated the contest, there were just six points in it at half-time and a five-point difference in the closing stages.
Italy pushed for a try that would have earned them a shock result in Edinburgh, but Blair Kinghorn's superb third try at the death killed off the visitors' hopes.
Scotland's all-time record try scorer Hogg, who was working as a pundit for BBC Sport after being ruled out of the contest through injury, accepts lessons must be learned by his side.
"It was very frustrating to watch. For Scotland, we were in control for large periods and then last 10 minutes was harum-scarum," he said.
"We can count ourselves lucky. That last try doesn't reflect the scoreline. It's a Scotland win, five points in a Test match and that's all you can ask for.
"We'll learn a hell of a lot from that and it'll stand us in good stead going forward. If you're not on it for 80 minutes, you aren't going to win Test matches."
All together to the very, very end. #AsOne | @DoveMenUK pic.twitter.com/Cp8IcdR9W6— Scottish Rugby (@Scotlandteam) March 18, 2023
Duhan van der Merwe superbly reached over for the first try, either side of a couple of Tommaso Allan penalties, before Kinghorn crossed over twice either side of half-time.
Allan chased down a grubber and then added three more points from the boot to set up a tense conclusion, but Kinghorn's brilliant breakaway third got Scotland over the line.
Scotland have won their last eight Six Nations matches against Italy, with that their longest winning run against any nation in the tournament.
Jack Dempsey, whose 23 tackles without missing one was the second-highest return of any player in this year's tournament, told BBC Sport: "It was a bit scary towards the end.
"Credit to the front row at the end there with a great scrum to get us our of trouble. But yeah, it was knee-shaky stuff. Honestly, I was just waiting for the whistle to go."
Scotland are set for their highest finish since 2018, having won three out of their five games for the fifth time in the past seven editions of the tournament.
As for Italy, they have collected the wooden spoon for eight years running and have won just one of their past 42 Six Nations games, coming against Wales 12 months ago.
After putting in another brave showing, head coach Kieran Crowley is hopeful Italy's time will come.
"We keep turning up at the office and hopefully a bounce will go our way one day," he said. "It was one hell of a game – they gave it everything, we gave it everything.
"It's not for lack of effort. We're playing an up-tempo game – we have to keep putting our players under that pressure in training and learn to execute a little bit better."