At dawn, Key was able to see an American flag waving, and he later wrote a poem about his experience entitled "Defence of Fort M'Henry" which was published in William Pechin's "American and Commercial Daily Advertiser" on September 21, 1814. He took it to music publisher Thomas Carr, who adapted it to the rhythms of composer John Stafford Smith's "To Anacreon in Heaven", a popular tune that Key had already used as a setting for his 1805 song "When the Warrior Returns", celebrating American heroes of the First Barbary War. It was somewhat difficult to sing, yet it became increasingly popular, competing with "Hail, Columbia" (1796) as the de facto national anthem by the time of the Mexican–American War and the American Civil War. The song was finally adopted as the American national anthem more than a century after its first publication, first by an Executive Order from President Woodrow Wilson in1916, and then by a Congressional resolution in1931 signed by President Herbert Hoover.