fixed potential infinite loop
Merge pull request #1 from mortenbpost/infinite-loop-fix

fixed potential infinite loop