Added functional cpp version