refactor, add test