finished 1st round of refactoring