finding cycles with loop problem solved