add test and refactor for it