almost done with refactor