Last Version before move to Rcpp