added 2 functions to process records