fix a bug which can lead into an infinity loop.
Merge pull request #33 from croath/master

fix a bug which can lead into an infinity loop.