fixed is_valid_char for real