sapply caused a matrix to come back in some situations and ended up repeating some fragments