Algorithm fixed to avoid loops
Merge pull request #4 from pedrobenedicte/master

Algorithm fixed to avoid loops