fix bug and add test case for ex2.29