v1
add test cases
add comment
simplify code