refactor, tests, coverage