Remove is_valid_utf8 method in generate