An American passenger who placed a fake bomb in a restroom during an international flight has avoided a prison term.

U.S. District Court Judge Michael Mosman sentenced Sean Davies to five years on probation and ordered him to pay restitution to KLM Royal Dutch Airlines. Prosecutors recommended the sentence because the Warrenton, Oregon, man had no prior arrests and has been getting treatment for alcoholism.

The plane was headed to Kilimanjaro, Tanzania, from Amsterdam in 2014 when Davies alerted a crew member to the device.

He later confessed he built it with a wine bottle, an iPhone charging cord and other materials handy on the flight. Davies told investigators that he had been feeling down and wanted to appear heroic by reporting the presence of a bomb.

He apologized Thursday to the airline, the passengers, the government and to his family.