updated cycle finding

Tried to find a way to make code of structure better implementing in this one