second stage of refactoring