better way to check if struct field is valid