change LinkedList to matrix