rewrite using lambda