Based on the converter by egret.net