almost ready cpp version