rewrite dependency logic