finished refactoring, confirmed that all driver code tests pass