initial working version of the cpp function that can be called after running the require(miro). sourceCpp needed bug fixed.