fixed the as.matrix issue