adding cycle detection and removal to ahrsz