rewrite of functions