prevent infinite loop
Merge pull request #209 from mahkoh/factor

prevent infinite loop