code optimization
add unit test