refactor
add test code