Ideally, if a closed contour is found it should have a known direction (eg. anticlockwise). It seems that currently the direction is random?