Refactor save/factors to helper.R