passed all test cases. fix #8