finish refactor