finished refactoring (no tests)