move BOM-stripping to private function, for reusability