Changed R code for checking sequences to C++ code