rewrite by cpp