first changes to cpp implementation