Ed Sheeran revealed that “Love Yourself,” the smash ballad he co-wrote for Justin Bieber‘s album Purpose, was originally meant for his own third album, Divide. In an interview with Carson Daly this morning, Sheeran explained he was even about to scrap the song entirely before Bieber got his hands on it and brought it back from the dead.

“That was a song I had written for Divide that It just wouldn’t have made it,” he told Daly. “And then Justin took it and did his thing on it, and released it as a single and made it what it is. Going from a song that would have never been released to [being] the biggest song of last year…it just shows you that you shouldn’t always write stuff off.”

That wasn’t the only time his work was unexpectedly revived by Bieber. Sheeran admitted that he totally forgot about writing “Cold Water,” which went on to become a hit Major Lazer collab with Bieber, before hearing it once it was out. As he tells it:

“‘Cold Water’ was a weird one because I didn’t even know that song existed. It was a song I must’ve half-written somewhere at a time where I was writing a lot of songs, and I did it at Benny Blanco’s house and then I got an email from Diplo just being like, ‘Yo! That ‘Cold Water’ song is dope! Can I have it?’ And I was like, ‘I have no idea what you’re talking about.’ And then he emailed and was like, ‘Yo, Justin [Bieber] wants to hop on the ‘Cold Water’ song. Is that cool?’ And I’m just like, ‘What are you talking about?’ And then the song came out and it was number one and I was like ‘Oh, that song!’ I remember doing it, but it was really, really slow…I remember hearing it and being like ‘That kind of sounds like me. Oh wait, it was me.'”

This is how the sausage is made, folks. Magical. Hear the whole interview below.