added break condition and removed do loop
Merge pull request #8 from HarrisYip/master

added break condition and removed do loop