adapted to format trained in the matrix