bug fix and refactor grammar
fix test case and bug fix