finish refactor better