rewrite scanning