finshed matrix.c