code to update records - see comments and new lines