Refactor/the matrix