Move the processing code to a seprate function.