add test, refactor