A bungling burglar raided the wrong house - and was caught returning his stolen loot, Merthyr Tydfil Crown Court heard.
Gareth James, 41, broke into a house believing it was the home of someone who owed him £400 - but it was the wrong address.
A court heard he stole a laptop in the break-in and only realised his mistake when he turned it on to see it the wrong name.
James, of Llanfaes, near Brecon, then decided to return the laptop - but was arrested after calling back at the house.
Prosecutor Rachel Knight told how James confessed to a barmaid at the Boar's Head pub about his crime.
Miss Knight said: "He told her he had done something stupid. He felt embarrassed he had gone into the wrong house."
James told her he had gone into the house thinking that the occupier owed him £400 for building work but his only intention was to keep the laptop until he paid up.
But when he opened it up and saw the name Ben Price on the screen he realised he had gone into the wrong house.
Student Benjamin Price, 23, discovered the laptop had been taken from the sofa of his home in Brecon.
James admitted burglary after he was caught when he went back to the house with the laptop - and let himself in through an open door.
Judge Richard Twomlow jailed James for four months suspended for 12 months with supervision and ordered him to complete the thinking skills programme.