rewrite with closure