add flush to save method