* clean up the code and comments, and add more test case