on second thoughts, remove the duplicated code and make the XML declaration optional too.