first rough refactoring