first part of refactoring