finished first stage of refactorization