finishing first stage of refactoring