refactoring
add the lost test.gradually generalize the code.