Code to process records in parallel