Map function to iterate through a record set