Factorised record processing into a separate function