issue #4

1. add a test case
2. add a recursive method, it is really teadious and easy to make mistake