hasCicle method fixed