allow extraFields to be a function