Use variable for total records
use save method to aovid error when inserting a document that already exists