Implemented cycles detection