made getMatrix faster