fix infinite loop
Merge pull request #319 from chenyukang/fix_infinite_loop

fix infinite loop