fix rewrite and sample file