automatically detect field type