beginning of refactoring