fixed #3  infinite loop