bad encoding handling more robust