add cycle detect