replace apply(cbind(sum()))) with rowSums which seems to be 100 times faster