rewrited function