rewrite without function