rewrite create function