first draft of refactoring