simplify code
Merge pull request #653 from lichuan/master

simplify code