adding a count in the a star loop (you can now click in a closed area without bugging the algorithm)