BOM detection will be used in other code too. I'll put it in one line.