refactor, tests