continue to use Rcpp (I will improve the code later...)