refactor to guess the field type