Break out field handling code into separate function