cleaned up and looked at using Rcpp11