Convert to Rcpp