rewrite creating directories