Added working cpp version