Modified is_valid_name routine