simplify code
add more test cases