finished refactor