finished majority of refactor