the issue is certainly the random access in R with X_indices[jj]
I don't know how to avoid it