rewrite with cpp