Break record formatting out into its own function