new helper function trimFields()