debug rewrite