rewrite filename handling