Refactored to make batch save more functional