rewrite has cycle