first stage of refactoring