finished refactoring