build_index_cpp was not subsetting all the varoables but only those in attr(vars)