write regressions out to a file. refactor some code