started converting cpp code