Rewrite document controller