scope error if rewrite is used